+ Reply to Thread
Results 1 to 3 of 3

Boolean variable initial state

  1. #1
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Question Boolean variable initial state

    Ok, time for an easy one

    Are Boolean variables ALWAYS initialised as FALSE when they are created?

    I am wanting to leave a 'marker' in a function so that I know whether it is the first time it has been used or not. Something similar to this:

    Please Login or Register  to view this content.
    This will work if I can rely on the fact that 'BeenHereBefore' is going to alway be initialised as FALSE, but I just wanted to check that was the case

    Cheers!

    Edit
    I should have said, obviously the above Sub would be called repeated from another routine.
    Also I know that STATIC will cause it to retain it's value when this Sub is exited, but once all Subs have been exited and everything stops, if i was then to run the macro again would this variable reinitialise back to FALSE, or keep it's TRUE setting from the previous run?
    Last edited by Phil_V; 07-15-2009 at 08:31 AM.
    If you find the response helpful please click the scales in the blue bar above and rate it
    If you don't like the response, don't bother with the scales, they are not for you

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Boolean variable initial state

    Yes they are, in every current version of VBA.
    It will remain True until you close the workbook and reopen it, or unless you run an End statement somewhere in that project.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Boolean variable initial state

    Many thanks RS

+ 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