This documentation is archived and is not being maintained.

6.2.1 Option Explicit Statement

Visual Studio .NET 2003

The Option Explicit statement determines whether local variables may be implicitly declared. The keywords On or Off may follow the statement; if neither is specified, the default is On. If no statement is specified in a file, the compilation environment determines which will be used.

Note   Explicit and Off are not reserved words.
Option Explicit Off

Module Test
    Sub Main()
        x = 5 ' Valid because Option Explicit is off.
    End Sub
End Module

In this example, the local variable x is implicitly declared by assigning to it. The type of x is Object.

OptionExplicitStatement ::= Option Explicit [ OnOff ] LineTerminator
OnOff ::= On | Off

See Also

6.2.2 Option Strict Statement | 6.2.3 Option Compare Statement | 6.2.4 Integer Overflow Checks | 6.2 Compilation Options | 10.1.1 Local Variables and Parameters | Option Explicit Statement (Visual Basic Language Reference)

Show: