Skip to content

Latest commit

 

History

History
56 lines (45 loc) · 2.34 KB

File metadata and controls

56 lines (45 loc) · 2.34 KB
title -optionexplicit
ms.date 07/20/2015
ms.prod .net
ms.suite
ms.technology
devlang-visual-basic
ms.topic article
f1_keywords
/optionexplicit
-optionexplicit
helpviewer_keywords
/optionexplicit compiler option [Visual Basic]
optionexplicit compiler option [Visual Basic]
-optionexplicit compiler option [Visual Basic]
ms.assetid 5d296ab3-bafe-4c4d-9887-78f162ed86c7
author dotnet-bot
ms.author dotnetcontent

-optionexplicit

Causes the compiler to report errors if variables are not declared before they are used.

Syntax

-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 enables implicit declaration of variables.

Remarks

If the source code file contains an Option Explicit statement, the statement overrides the -optionexplicit command-line compiler setting.

To set -optionexplicit in the Visual Studio IDE

  1. Have a project selected in Solution Explorer. On the Project menu, click Properties.

  2. Click the Compile tab.

  3. Modify the value in the Option Explicit box.

Example

The following code compiles when -optionexplicit- is used.

[!code-vbVbVbalrCompiler#5]

See Also

Visual Basic Command-Line Compiler
-optioncompare
-optionstrict
-optioninfer
Sample Compilation Command Lines
Option Explicit Statement
Visual Basic Defaults, Projects, Options Dialog Box