VBScript » Statements » Option Explicit

Version: 1.0

Syntax:
<%Option Explicit%>

The Option Explicit statement forces the explicit declaration of all variables using the Dim, Private, Public, or ReDim statements.

In a long program, this statement prevents the accidental reuse of the name of a previously declared variable. Also, if you mistype a declared variable's name or try to use an undeclared variable, an error message is generated.

Examples

Code:
<% Option Explicit %>
< HTML >
< HEAD >
< TITLE > EXAMPLE < /TITLE >
< /HEAD >
< BODY >
<%
Dim myvariable,yourvar
myvariable = 123.456
yourvar = 0
%>
< /BODY >
< /HTML >
Explanation:

Note that the Option Explicit statement must be placed at the top of the code before any other VBScript commands or any HTML code.

Language(s): VBScript