Returns a Variant containing an array.
Array(arglist)
The arglist consists of a comma-delimited list of an arbitrary number of values that are assigned to the elements of the array contained within the Variant. If no arguments are specified, an array of zero-length is created.
Although a Variant containing an array is conceptually different from an array whose elements are of type Variant, the way the array elements are accessed is the same. The notation used to refer to an element of an array consists of the variable name followed by parentheses containing an index number indicating the desired element. In the following example, the first statement creates a variable A as a Variant. The second statement assigns an array to variable A. The final statement illustrates how to assign the value contained in the second array element to another variable.
Dim A As Variant= Array(10,20,30)= A(2)
The lower bound of an array created using the Array function is determined by the lower bound specified with the Option Base statement.
Note A Variant not declared as an array can still contain an array. A Variant variable can contain an array of any type, except fixed-length strings and user-defined types.
Deftype Statements, Dim Statement, Let Statement, Option Base Statement, Variant Data Type.
This example uses the Array function to return a Variant containing an array.
MyWeek = Array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun") ' Return values assume lower bound set to 1 (using Option Base ' statement).= MyWeek(2) ' MyDay contains "Tue".= MyWeek(4) ' MyDay contains "Thu".