Results 1 to 3 of 3

Thread: [RESOLVED] Accessing variables

Hybrid View

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2005
    Location
    Arlington, TX
    Posts
    60

    Resolved [RESOLVED] Accessing variables

    If I have a macro with two subs, how would I get one of them to access variables declared in the other? I thought it was just SubName.VariableName, but that's not working...

    example:
    VB Code:
    1. Sub Main()
    2.    Dim Variable1 as Integer
    3. End Sub
    4.  
    5. Sub NotMain()
    6.    ' how do I access Variable1?
    7. End Sub

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Accessing variables

    You can't do it like that I'm afraid, you need to declare the variable in the General Declarations section (before the "Sub Main()" line), then both Sub's can access it.

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2005
    Location
    Arlington, TX
    Posts
    60

    Re: Accessing variables

    .........wow......
    It's been so long since I've worked with VB, I had forgotten about the General Declarations....

    Thanks for the help.

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