473,395 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Syntax question: #If bla bla bla then

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
Dec 22 '05 #1
3 1169
hi moondaddy,
On the surface, the behavior of the #If...Then...#Else directives
appears the same as that of the If...Then...Else statements. However,
the #If...Then...#Else directives evaluate what is compiled by the
compiler, whereas the If...Then...Else statements evaluate conditions
at run time.

Conditional compilation is typically used to compile the same program
for different platforms. It is also used to prevent debugging code from
appearing in an executable file. Code excluded during conditional
compilation is completely omitted from the final executable file, so it
has no effect on size or performance.

Regardless of the outcome of any evaluation, all expressions are
evaluated using Option Compare Text. The Option Compare statement does
not affect expressions in #If and #ElseIf statements.

Note:
you can get more details on this by searching in the msdn

Dec 22 '05 #2
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

Dec 22 '05 #3
"moondaddy" <mo*******@nospam.nospam> schrieb:
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


I suggest to read the documentation on "#If directive".

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
12
by: Steven Bethard | last post by:
The poll, as stated, asked voters to vote for the syntax suggestion they liked the /most/. Some of the conclusions people are trying to draw from it are what syntaxes people liked the /least/. ...
4
by: ben | last post by:
getting a bit confused with the details of how c's grammar is specified, especially when you get self-reference like in this: postfix-expression: primary-expression postfix-expression ...
4
by: Bob hotmail.com> | last post by:
Everyone I have been spending weeks looking on the web for a good tutorial on how to use regular expressions and other methods to satisfy my craving for learning how to do FAST c-style syntax...
8
by: Rich | last post by:
Hello, If I leave Option Strict Off I can use the following syntax to read data from a Lotus Notes application (a NotesViewEntry object represents a row of data from a Lotus Notes View - like a...
5
by: r.nikhilk | last post by:
Hi, Currently, we are porting C++ applications from 32 bit to 64 bit on AIX platform. (The current version of AIX is 5.3 and xlC verison is 8.0). We are able to compile the applications by...
2
by: JJA | last post by:
I'm looking at some code I do not understand: var icons = new Array(); icons = new GIcon(); icons.image = "somefilename.png"; I read this as an array of icons is being built. An element of...
8
by: Smithers | last post by:
Are there any important differences between the following two ways to convert to a type?... where 'important differences' means something more profound than a simple syntax preference of the...
17
by: trose178 | last post by:
Good day all, I am working on a multi-select list box for a standard question checklist database and I am running into a syntax error in the code that I cannot seem to correct. I will also note...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.