#Const SPECIAL = 1
' Local variable.
Dim a As Integer = 1' Use special value is SPECIAL is 1.#If SPECIAL = 1 Then
a = 2#End If
' Display value.
Region. Another directive available in VB.NET programs is #Region. This directive partitions a code file. It has no effect on the compiled program.
Info We use #Region to organize code. In Visual Studio, a region can be collapsed and expanded.
Also Regions are used by Visual Studio when auto-generation of code files is performed, as for Windows Forms.
Note Regions in VB.NET cannot be used in all locations. They must enclose an entire Function body or other unit of code.
''' Initialize the program.
A discussion. Preprocessing directives are handled at an early stage of compilation. The preprocessor scans VB.NET programs before compiling code statements into intermediate language.
Info Directives are separate from the rest of the VB.NET code. This gives them special abilities.
And With preprocessing directives, no performance loss is incurred with branches of an #If. The branches are handled before execution.
Warning One problem with preprocessing directives is bit rot. Code that is not compiled because of an #If may become buggy or invalid.
A summary. Directives add another layer of compilation to VB.NET programs. With #If, #Const and even #Region, we access another set of abilities in this language.