Fixed Size Arrays
To declare a fixed size array, the array name must be followed by the upper bound subscript enclosed within parentheses. The upper bound must be an integer.
Dim ArrayName(10) As Integer
Dim Sum(20) As Double
Unless specifically defined in the array
declaration statement, default lower bound settings are used. The
default lower bound is zero, unless set by the module option base
statement setting. For details, see
Array Subscripts.
The first declaration in the previous example
creates an array with 11 elements, with index numbers running from
0 to 10. The second creates an array with 21 elements (if base 0).
One way to specify the lower bound is to provide it explicitly (as
an integer in the range -32,768 to 32,767) using the To
clause within the
subscript:
Dim intCounters (1 To13) As Integer
Dim strSums (100 To126) As String
In the preceding example, the index numbers of
intCounters
run from 1-13, and the
index numbers of strSums
run from
100-126.
Note: An array in CitectVBA must be declared before it can be referenced.
Loops often provide an efficient way to manipulate
arrays. For example, the following for
loop initializes all elements in the array
to 5:
Dim int As IntegerDim Counters(1 To 20) As Integer
For int = 1 To 20
Counters(int) = 5
Next int
Arrays declared (using the dim
statement within procedures) do not retain
their values between procedure calls in CitectVBA.
See Also