Conditional Compilation

As with other languages it is possible to create "debug" and "release" versions of your code.
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.
In contrast to a normal If statement this condition to executed at compile time and only the appropriate branch is included.
There is no loss in speed of execution.

#IF debug = 1 Then 



You can also use the #Const directive to create other compiler variables.

# Const 

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.

© 2017 Better Solutions Limited. All Rights Reserved. © 2017 Better Solutions Limited