Visual Basic Compiler Options |
|
Causes the compiler to report errors if variables are not declared prior to use.
/optionexplicit[+ | -]
Arguments
- + | -
- Specify /optionexplicit+ to require explicit declaration of variables. /optionexplicit- is the default; /optionexplicit+ is the same as /optionexplicit. Both let you declare variables implicitly.
To set /optionexplicit in the Visual Studio integrated development environment
- Open the project's Property Pages dialog box. For details, see <Projectname> Property Pages Dialog Box.
- Click the Common Properties folder.
- Click the Build property page.
- Modify the Option Explicit property.
To set /optionexplicit programmatically
- See OptionExplicit Property.
Example
The following code compiles when /optionexplicit- is used:
Module Module1
Sub Main()
i = 99
System.Console.WriteLine(i)
End Sub
End Module
See Also
Visual Basic Compiler Options | /optionstrict | Sample Compilation Command Lines