Name
Array Function
Syntax
Array([element1], [elementN],....)
elementUse: Optional
Data Type: Any
The data to be assigned to the first array element.
elementNUse: Optional
Data Type: Any
Any number of data items you wish to add to the array.
Return Value
A variant array consisting of the arguments passed into the function.
Description
Returns a variant array containing the elements whose values are passed to the function as arguments.
The code fragment:
Dim vaMyArray
vaMyArray = Array("Mr", "Mrs", "Miss", "Ms")is similar to writing:
Dim vaMyArray(3) vaMyArray(0) = "Mr" vaMyArray(1) = "Mrs" vaMyArray(2) = "Miss" vaMyArray(3) = "Ms"
Because Array creates a variant array, you can pass any data type, including objects, to the Array function. You can also pass the values returned by calls to other Array functions to create multidimensional arrays; these kinds of arrays are called “ragged” arrays.
Rules at a Glance
Although the array you create with the Array function is a variant array data type, the individual elements of the array can be a mixture of different data types.
The initial size of the array you create is the number of arguments you place in the argument list and pass to the Array function.
The lower bound of the array created by the Array function is 0.
The array returned by the Array function is a dynamic rather than a static array. Once created, you can redimension the array using
Redim,RedimPreserve, or another call to the Array function.If you don’t pass any arguments to the Array function, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access