Development vb global veribles

Discussion in 'Software' started by ahug4122, 22 Nov 2004.

  1. ahug4122

    ahug4122 What's a Dremel?

    Joined:
    16 Sep 2004
    Posts:
    60
    Likes Received:
    0
    i need to know the coding to make a global string

    i know its
    dim pop As String

    but where do i put it to be a global string????
     
  2. mottl3y

    mottl3y What's a Dremel?

    Joined:
    1 Nov 2004
    Posts:
    156
    Likes Received:
    0
    its been a little while, but i think you have to make a new module, and then declare the variable as public in the module:

    Code:
    Public pop as String
     
  3. ahug4122

    ahug4122 What's a Dremel?

    Joined:
    16 Sep 2004
    Posts:
    60
    Likes Received:
    0
    i have never used a module i do very basic stuff
     
  4. mottl3y

    mottl3y What's a Dremel?

    Joined:
    1 Nov 2004
    Posts:
    156
    Likes Received:
    0
    uhh, try file>new>module or find the menu somewhere to add a new module.
    then go into the code of the module (itll appear with the forms) and add that code above.

    i think.
     
  5. BjD

    BjD What's a Dremel?

    Joined:
    10 Apr 2003
    Posts:
    935
    Likes Received:
    0
    Can't you just pop it in the 'General Declarations' ? Only really need a module if theres more then one form.
     
  6. Hepath

    Hepath Minimodder

    Joined:
    20 Oct 2003
    Posts:
    730
    Likes Received:
    0
    Open up the project and go to the "project explorer" window.

    Right click the folder or any project item for the project and select add->module. This will create a module (.bas) file. This will open up a dialog window. Just select OK - you can rename it later.

    You can then declare your vaiables into the file and scope them using the standard access modifiers (public, private, etc.)

    e.g.
    Private Const my_private_constant_global_string As String = "constant value"
    Public Const my_public_constant_global_int As Integer = 34
     
  7. mcbeckel

    mcbeckel What's a Dremel?

    Joined:
    31 Aug 2003
    Posts:
    76
    Likes Received:
    0
    :idea: Try to avoid using global variables if possible; it makes for sloppy code. One of VB 's Object Orientated ways to pass variables to a different form is using the "Get" and "Let" property.

    Here is a link which explains it: http://www.developerfusion.com/show/3959/7/

    Let me know if you try this route and need any help.
     

Share This Page