+ Reply to Thread
Results 1 to 2 of 2

global Variables

  1. #1
    Mike
    Guest

    global Variables

    Why do my variable seem to not be global? I have two subs:

    Sub A()
    Static CountRows As Long
    CountRows = 1
    MsgBox (CountRows)
    End Sub

    This one shows that CountRows = 1

    Sub Bt()
    Static CountRows As Long
    MsgBox (CountRows)
    End Sub

    But when I run this one it does not remember CountRows = 1, and resets it to
    zero. Why?

  2. #2
    Gary''s Student
    Guest

    re: global Variables

    You need to Dim you variable outside and before your Subs. This make them
    "global".
    --
    Gary''s Student


    "Mike" wrote:

    > Why do my variable seem to not be global? I have two subs:
    >
    > Sub A()
    > Static CountRows As Long
    > CountRows = 1
    > MsgBox (CountRows)
    > End Sub
    >
    > This one shows that CountRows = 1
    >
    > Sub Bt()
    > Static CountRows As Long
    > MsgBox (CountRows)
    > End Sub
    >
    > But when I run this one it does not remember CountRows = 1, and resets it to
    > zero. Why?


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1