If you know at compile time that a certain part of your program is never
going to be used there isn't much point in including it. It will only make
the program slower and larger.
The most common use if #If...#Else is to separate debug code from release
code. You might have additional debuging code that shouldn't be included in
the release build. Instead of deleting it and retyping it every time you
need it, you can use #If...#Else to have the compiler automatically include
it in debug builds and remove it in release builds.
We use it in our application to include extensive exception handling in
release builds since we don't want our users to experience a sudden crash
when something goes wrong. In the debug builds this exception handling is
turned off because we actually want it to crash immediately if something
goes wrong, in order to find out why and where it happened.
/claes
"moondaddy" <mo*******@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I'm looking at some sample code but dont know what to make of it. I see
an If block that looks like this:
#If bla bla bla then
Private function xyz() as Boolean
'bla bla bla
End Function
More stuff
#Else
Private function 123() as Boolean
'bla bla bla
End Function
More stuff
#End If
Why wouldnt you just write this:
If bla bla bla then
x=xyz
More stuff
Else
x=123
More stuff
End If
Private function xyz() as Boolean
'bla bla bla
End Function
Private function 123() as Boolean
'bla bla bla
End Function
Thanks.
--
mo*******@nospam.nospam