Array Variables

Array variables store a list or table of values. A single variable name refers to the entire collection, and individual values are distinguished by their numeric indices (their "subscripts"). The maximum number of values that can be stored in an array must be defined in a Dim statement. The elements of an array are accessed by using the variable name followed by a left parenthesis, the index of an array element, and a right parenthesis.

 

Dim month(11) As String

month(0) = "January"

month(1) = "February"

month(11) = "December"

 

Array subscripts begin with zero, unless an Option Base statement is used at the start of a script. Notice that in the previous example an array whose maximum subscript value is 11 actually has room for twelve elements because the subscripts start with zero.

 

The Dim statement can reserve only a constant number of elements for an array. If the maximum number of elements cannot be known in advance, a dynamic array may be used. A dynamic array is an array whose number of elements can be changed while a script is running. The Redim statement changes the maximum number of values that can be stored in a dynamic array. Refer to Help | BASIC Language Help in Scripter for more information on Dim and ReDim.

 

 

See Also

Variables

Object Variables

User-Defined Types

Global Variables

Scripter BASIC Language