Name
Array Function
Syntax
Array([element1], [elementN],....)
-
element Use: Required
Data Subtype: Any
The data to be assigned to the first array element.
-
elementN Use: Optional
Data Subtype: 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 equivalent 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 datatype, including objects, to the
Array function. You can also pass the values
returned by calls to other Array functions to
create multidimensional arrays (but see the comment on
multidimensional arrays in the “Programming Tips &
Gotchas” section).
Rules at a Glance
Although the array you create with the
Arrayfunction is a variant array datatype, the individual elements of the array can be a mixture of different data subtypes.The initial size of the array you create is the number of arguments you place in the argument list and pass to the
Arrayfunction.The lower bound of the array created by the
Arrayfunction is 0.The array returned by the
Arrayfunction is a dynamic rather than a static array. Once created, you can redimension the array usingRedim,RedimPreserve, or another call to theArray ...
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