Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Causes the compiler to report errors if variables are not declared prior to use.
/optionexplicit[+ | -]
Arguments
- + | -
Optional. Specify /optionexplicit+ to require explicit declaration of variables. The /optionexplicit+ option is the default and is the same as /optionexplicit. The /optionexplicit- option allows implicit declaration of variables.
Remarks
To set /optionexplicit in the Visual Studio integrated development environment
Have a project selected in Solution Explorer. On the Project menu, click Properties. For more information, see Introduction to the Project Designer.
Click the Compile tab.
Modify the value in the Option Explicit box.
To set /optionexplicit programmatically
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
Reference
/optioncompare
/optionstrict
Sample Compilation Command Lines
Option Explicit Statement (Visual Basic)
Visual Basic Defaults, Projects, Options Dialog Box