Results 1 to 6 of 6

Thread: Newbie Stuff

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    9

    Question

    How can I have a variable that I can access in all sub procedures and forms? Is there any way that I can somehow pass a parameter to another form?

    If the answer to my question involves modules can someone explain what they are and how I can use them.

    Thanks to everyone who has helped with my VB problems!!!

  2. #2
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    where you have your form listing (on the right usually) right click and select add module. then, click ok for the default module.

    you can declare your PUBLIC variables there, which will be available from every form class, etc.

    Check out msdn.microsoft.com for more info (or your online help).
    -Excalibur

  3. #3
    Guest
    Do you want to have one variable be accessed by multiple
    forms? You can declare it in a module. You would add
    a module through the Projects Menu, and then declare
    whatever project-wide variables in that newly created
    module file.

    Sherm

  4. #4
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539
    modules are a place where you put all your global variables and procedures

    if you declare them as public
    you can use them in any form or parts of the project

    to add a module
    on menu
    Project>Add Module
    then type your variables
    such as

    Code:
    Public myVar as String
    
    public sub SayHi()
       msgbox "hi"
    end sub
    you can also put
    public myVar as string
    in a form as well

    but to access this from other parts you have to call it by the form name as well

    so if you put

    public myVar as string
    in form1

    you have to call this variable as

    Form1.MyVar


  5. #5
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539
    wow, while i was writting my answer
    2 people answered..
    this forum rocks
    (the people on this forum make it rock)

  6. #6

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    9

    Smile Rocking

    Thanks Everyone, You are right, this forum does Rock!

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