Option Definition

Syntax

Option Base [0|1]
-or-
Option Explicit
-or-
Option Private Module

Group

Declaration

Description

Form 1: Set the default base index for array declarations. Affects Dim, Static, Private, Public and ReDim. Does not affect Array, ParamArray or arrays declare in a Type. Option Base 0 is the default.

Form 2: Require all variables to be declared prior to use. Variables are declared using Dim, Private, Public, Static or as a parameter of Sub, Function or Property blocks.

Form 3: Public symbols defined by the module are only accessible from the same project.

See Also: Dim, Private, Public, ReDim, Static.

Example

Option Base 1
Option Explicit

Sub
Main
Dim
A
Dim
C(2) ' same as Dim C(1 To 2)
Dim
D(0 To 2)
A = 1
B = 2 ' B has not been declared
End
Sub