CitectVBA Programming Reference > CitectVBA Function Reference > Declarations > Option Base

Option Base

Declares the default lower bound for array subscripts.

The Option Base statement is optional. If used, it can appear only once in a CitectVBA file, and must be used before you declare the dimensions of any arrays.

The To clause in the array subscript range of a Dim statement provides a more flexible way to control the lower bound of an array. If you don't explicitly set the lower bound with a To clause, the Option Base setting (if used) comes into affect, or defaults to zero (if not used).

Syntax

Option BaseNum

Num:

An Integer or expression representing a valid numeric value. The value of the 'number' parameter must be either 0 or 1. The default is 0.

Related Functions

Dim | ReDim

Example

The example below uses the Option Base statement to override the default base array subscript value of 0.

' Module level statement
Option Base 1

' Create the array
Dim Arr(20)
' Declare message variables
Dim Msg As String
Dim NL as String
' Define newline
NL = Chr(10) & Chr(13)
' Create message
Msg = "The lower bound is " & LBound(Arr) & "."
Msg = Msg & NL & "The upper bound is " & UBound(Arr) & "."
' Display message
MsgBox Msg