Arrays II
row number and a column number. Using both, a every
2-D array element can
be uniquely identified.
To create a two-dimensional array, we use the following syntax:
Dim|Public|Private ArrayName(col_subscript, _
row_subscript) As DataType
In this syntax,
- Dim, Public, and Private are Visual Basic keywords that declare the array
and its scope. If you use Dim, the array is private to the procedure in
which it's declared. Public makes the array visible from anywhere in the
program, and Private (within a form or module's General section) makes the
array visible only to the form or module in which it's declared. Using Dim
within a module automatically makes the array available anywhere in the
program, as if the Public keyword were used.
- ArrayName is the name of the array.
- col_subscript is the number of the highest column in the array.
- row_subscript is the number of the highest row in the array.
- As is the Visual Basic keyword that denotes type declaration.
- DataType is any valid Visual Basic data type.
We shall study use of loops to traverse arrays in the next article.