Conditional Compilation
In contrast to a normal If statement this condition to executed at compile time and only the appropriate branch is included.
As with other languages it is possible to create "debug" and "release" versions of your code.
You can also use the #Const directive to create other compiler variables.
#Const g_Conditional = 1
You can define a constant in (Project Properties)(General tab) in the text field Conditional Compilation Arguments
In the program code you can then make use of the value of this constant with #IF statements.
There is no loss in speed of execution.
#If g_Conditional = 1 Then
#Else
#EndIf
For example you may want to include extra message boxes, or use Debug.Print or Debug.Assert statements while you are developing and testing your code but don't want these incorporated when you distribute the code to the users.
Use the "#Const" directive to create a compiler variable. (#IF .THEN #ELSE #ELSEIF, #CONST).
Then use delimiter blocks using the compiler directive to include the extra blocks of code.
These are global in scope, ie they apply to the whole project.
The Option Compare statement does not affect expression in a #IF and #ELSEIF statements and these are always evaluated using Option Compare Text.
Keywords
Certain keywords cannot be used for your constants.
For example "debug" cannot be used.
#Const debug = 1
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext