NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

HxLink DID NOT INITIALIZE

#If...Then...#Else Directive

Conditionally compiles selected blocks of Visual Basic code.

#If expression Then
   statements
[#ElseIf expression-n Then
   [elseifstatements]]
[#Else
   [elsestatements]]
#End If

Arguments

expression
Required. Any expression, consisting exclusively of one or more conditional compiler constants, literals, and operators, that evaluates to True or False.
statements
Required. Visual Basic program lines or compiler directives that are compiled if the associated expression is True.
expression-n
Optional. Any expression, consisting exclusively of one or more conditional compiler constants, literals, and operators, that evaluates to True or False.
elseifstatements
Optional. One or more program lines or compiler directives that are compiled if expression-n is True.
elsestatements
Optional. One or more program lines or compiler directives that are compiled if no previous expression or expression-n is True.

Remarks

On the surface, the behavior of the #If...Then...#Else directive appears the same as the If...Then...Else statement. However, the #If…Then…#Else directive evaluates what is compiled by the compiler, whereas the If…Then…Else statement evaluates 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   No single-line form of the #If, #Else, #ElseIf, and #End If directives exists; that is, no other code can appear on the same line as any of the directives.

See Also

Example

#Const Directive | Compiler Constants | If...Then...Else Statement | Understanding Conditional Compilation | Using If...Then...Else Statements