Directives (Visual Basic)

 

Updated: July 20, 2015

For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

The topics in this section document the Visual Basic source code compiler directives.

#Const Directive -- Define a compiler constant

#ExternalSource Directive -- Indicate a mapping between source lines and text external to the source

#If...Then...#Else Directives -- Compile selected blocks of code

#Region Directive -- Collapse and hide sections of code in the Visual Studio editor

#Disable, #Enable -- Disable and enable specific warnings for regions of code.

#Disable Warning BC42356 ' suppress warning about no awaits in this method  
    Async Function TestAsync() As Task  
        Console.WriteLine("testing")  
    End Function  
#Enable Warning BC42356  
  

You can disable and enable a comma-separated list of warning codes too.

Visual Basic Language Reference

Visual Basic

Show: