| Option Base Statement |
Syntax
Option Base {0 | 1}
Description
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.
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 and 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
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access