Visual Basic Compiler Options  

/define

Defines conditional compiler constants.

/define:symbol=value[,symbol=value]

-or-

/d:symbol=value[,symbol=value]

Arguments

symbol
Required. The symbol to define.
value
Required. The value to assign symbol.

Remarks

The /define option has the same effect as using a #Const preprocessor directive in your source file.

You can use symbols created by this option with the #If...Then...#Else directive to compile source files conditionally.

/d is the short form of /define.

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. Open the project's Property Pages dialog box. For details, see <Projectname> Property Pages Dialog Box.
  2. Click the Configuration Properties folder.
  3. Click the Build property page.
  4. Modify the Conditional compilation constants property.

To set /define programmatically

Example

The following code defines and then uses two conditional compiler constants:

Vbc /define:DEBUGMODE=True,TRAPERRORS=False test.vb
Sub mysub()
   #If debugmode Then
      ' Place debug statements here.
       MsgBox("debug mode")
   #Else
      ' Place default statements here.
      '
   #End If
End Sub

See Also

Visual Basic Compiler Options | #If...Then...#Else Directives | #Const Directive | Sample Compilation Command Lines