Option Base Statement



Used at the beginning of a module to specify the default lower bound for arrays dimensioned within the module.

Rules at a Glance

• The default lower bound for arrays created in Visual Basic is 0. Therefore, you should only use Option Base 1 to change the default base for arrays to 1.

444 Chapter 7 - The Language Reference

• The Option Base statement must appear at the start of a module, before any array declarations.

• The Option Base statement affects only those arrays declared in the module in which the Option Base statement appears.

Programming Tips & Gotchas

• Another more flexible method of specifying the lower bound of an array (other than the default) is to use the To clause when dimensioning an array, as the following snippet shows:

Dim myArray(1 to 50) As String

• Option Base doesn't affect the lower bound of arrays created with the Array function or the ParamArray keyword; these are always base 0.

See Also

Dim, Private, Public, ReDim, Static Statements

0 0


  • franziska
    What is option base statement in vb?
    2 years ago

Post a comment