+ Reply to Thread
Results 1 to 3 of 3

What's the Difference?

  1. #1
    Registered User
    Join Date
    04-25-2006
    Posts
    21

    What's the Difference?

    What is the difference between:

    Global variable As Boolean

    Dim variable As Boolean

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Response

    It's all to do with variable visibility

    Dim X as Boolean

    means that X only is visible in the module in which its declared. It would be OK to have a different variable X in another module and the code would not get confused.

    Public X as Boolean

    means that X is visible across all modules and can be used in any.
    Martin

  3. #3
    Forum Contributor
    Join Date
    11-11-2005
    Posts
    267
    What is the difference between:
    Global variable As Boolean
    Dim variable As Boolean

    A variable can be "global" in 2 ways: (1) if it is accessible by all codes in a module or (2) if it is accessible by all codes in a project (across all modules).

    Both are accomplished by declaring the variable at the TOP of the module before the first Sub - in the case of the Ist with a DIM statement and for the 2nd with a PUBLIC statement.
    Last edited by Myles; 10-08-2006 at 07:26 AM.
    HTH
    Myles

    ...constantly looking for the smoother pebble while the whole ocean of truth lies before me.

+ 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