| title | -optionexplicit | |||
|---|---|---|---|---|
| ms.date | 07/20/2015 | |||
| ms.prod | .net | |||
| ms.suite | ||||
| ms.technology |
|
|||
| ms.topic | article | |||
| f1_keywords |
|
|||
| helpviewer_keywords |
|
|||
| ms.assetid | 5d296ab3-bafe-4c4d-9887-78f162ed86c7 | |||
| author | dotnet-bot | |||
| ms.author | dotnetcontent |
Causes the compiler to report errors if variables are not declared before they are used.
-optionexplicit[+ | -]
+ | -
Optional. Specify -optionexplicit+ to require explicit declaration of variables. The -optionexplicit+ option is the default and is the same as -optionexplicit. The -optionexplicit- option enables implicit declaration of variables.
If the source code file contains an Option Explicit statement, the statement overrides the -optionexplicit command-line compiler setting.
-
Have a project selected in Solution Explorer. On the Project menu, click Properties.
-
Click the Compile tab.
-
Modify the value in the Option Explicit box.
The following code compiles when -optionexplicit- is used.
[!code-vbVbVbalrCompiler#5]
Visual Basic Command-Line Compiler
-optioncompare
-optionstrict
-optioninfer
Sample Compilation Command Lines
Option Explicit Statement
Visual Basic Defaults, Projects, Options Dialog Box