Results 1 to 3 of 3

Boolean variable initial state

Threaded View

Phil_V Boolean variable initial state 07-15-2009, 07:58 AM
romperstomper Re: Boolean variable initial... 07-15-2009, 08:19 AM
Phil_V Re: Boolean variable initial... 07-15-2009, 08:31 AM
  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:

    Private Sub MyFakeSub()
    Static BeenHereBefore As Boolean
    
    If Not BeenHereBefore Then
        Call Init_Data
        BeenHereBefore=True
    End If
    
    ' More code
    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

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