The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.


Causes the compiler to report errors if variables are not declared prior to use.

/optionexplicit[+ | -]


+ | -
Specify /optionexplicit+ to require explicit declaration of variables. /optionexplicit+, which is the same as /optionexplicit, is the default. /optionexplicit- allows implicit declaration of variables.

To set /optionexplicit 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 Common Properties folder.
  3. Click the Build property page.
  4. Modify the Option Explicit property.

To set /optionexplicit programmatically

  • See OptionExplicit Property.


The following code compiles when /optionexplicit- is used:

Module Module1
   Sub Main()
      i = 99
   End Sub
End Module

See Also

Visual Basic Compiler Options | /optionstrict | Sample Compilation Command Lines | Option Explicit Statement

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft