/define (Visual Basic)
Updated: July 20, 2015
For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.
Defines conditional compiler constants.
/define:["]symbol[=value][,symbol[=value]]["] ' -or- /d:["]symbol[=value][,symbol[=value]]["]
|Required. The symbol to define.|
|Optional. The value to assign |
/define option has an effect similar to using a
#Const preprocessor directive in your source file, except that constants defined with
/define are public and apply to all files in the project.
You can use symbols created by this option with the
#Else directive to compile source files conditionally.
/d is the short form of
You can define multiple symbols with
/define by using a comma to separate symbol definitions.
|To set /define in the Visual Studio integrated development environment|
|1. Have a project selected in Solution Explorer. On the Project menu, click Properties. For more information, see Introduction to the Project Designer.|
2. Click the Compile tab.
3. Click Advanced.
4. Modify the value in the Custom Constants box.
The following code defines and then uses two conditional compiler constants.
' Vbc /define:DEBUGMODE=True,TRAPERRORS=False test.vb Sub mysub() #If debugmode Then ' Insert debug statements here. MsgBox("debug mode") #Else ' Insert default statements here. #End If End Sub