CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2000
    Location
    Holland
    Posts
    14

    Global variables

    Hi,

    Does anyone know how to declare global variables, which are available in the whole project(all the forms).
    Please send some code example, if possible.

    Thanx,
    Maarten


  2. #2
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Global variables

    Add a BAS module to your project (called modGlobals.BAS for example), then you can add global variables there, eg :


    public g_SomeGlobalString as string
    public Const SOME_CONSTANT as string = "Some string That Doesnt Change"
    public Const SECONDS_IN_AN_HOUR as Long = 60 * 60




    In Form1 - form_load procedure :


    MsgBox SOME_CONSTANT
    g_SomeGlobalString = "Something else"
    MsgBox g_SomeGlobalString





    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

  3. #3
    Join Date
    Jan 2000
    Location
    Holland
    Posts
    14

    Re: Global variables

    This one works also like I wanted.

    Thanx!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured