Conditionally compiles selected blocks of Visual Basic code.
#If expression Then statements [#ElseIf expression-n Then [elseifstatements]] [#Else [elsestatements]] #End If
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.
#Const Directive | Compiler Constants | If...Then...Else Statement | Understanding Conditional Compilation | Using If...Then...Else Statements