Subscripts


The subscripts of an array element denote the element within the array. In the simple case of a one-dimensional array, elements are numbered starting at 0 with the first element, 1 for the second element, and running to the subscript of the last element. Arrays with multiple dimensions are addressed by specifying a subscript expression for each dimension.

Subscripts may be used either to retrieve the value of one or more array elements or to designate array elements to receive new values.

x = a(12)

Here a(12) denotes the value of the thirteenth element of the array (because subscripts start at 0).

a(12) = 5

Here the number 5 is stored in the thirteenth element of the array without changing the other elements.

Elements of multidimensional arrays are specified by using one subscript for each dimension. The first subscripts vary fastest in memory.


Dim a(10,10)


The subscript list is simply a list of expressions, constants, or subscript ranges which contains the values of the one or more subscripts. Subscript expressions are separated by commas if there is more than one subscript.


n = 1
For j = 0 to 10
For i = 0 to 10

a(i,j) = n

n = n + 1

Next j
Next i



Arrays and Subscripts







Become a Patron