Multi-Dimensional Arrays
CitectVBA supports multi-dimensional arrays, declared using multiple subscripts. Each subscript must be separated by a comma, and each subscript represents a separate dimension of the array.
The following example declares a two-dimensional array.
Dim dblMat(20, 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 more
information on bounds, see "Array Subscripts in CitectVBA."
Reusing the previous example, either or both dimensions can be declared with explicit lower bounds.
Dim dblMat(1 To10, 1 To10) As Double
Arrays can be more than two dimensional. This declaration creates an array that has three dimensions with sizes 6 elements by 4 elements by 3 elements, using base 0:
Dim ArrTest(5, 3, 2)
You can efficiently process a multi-dimensional array with the use of for loops. In the following statements the elements in a multi-dimensional array are set to a value.
Dim L As Integer, J As Integer
Dim TestArray(1 To 10, 1 to 10) As Double
For L = 1 to 10
For J = 1 to 10
TestArray(L,J) = I * 10 + J
Next J
Next L
Arrays declared (using the dim
statement within procedures,) do not retain
their values between procedure calls in CitectVBA.
See Also