ARRAY(arglist)

Returns the array containing the given values (Variant).


arglist

The comma seperated list of values (Array / Variant).


Remarks
The array that is created is always 0 based.
This function ignores any Option Base 1 statements and always creates an array that is 0 based.
If the function is used with a type prefix (ie VBA.Array) then the Option Base 1 statement is taken into account and the array will be 1 based.
If no arguments are given, then a zero length array is returned.
A Variant that is not declared as an array can still contain an array.
A Variant variable that contains an array is different from an array of elements with type Variant although the array elements are accessed in the same way.

Dim iArray(4) As Integer 
iArray(0) = 1
iArray(1) = 2
iArray(2) = 3
iArray(3) = 4
   
Dim vArray As Variant
vArray = Array(1, 2, 3, 4)
iArray(0) = 1
iArray(1) = 2
iArray(2) = 3
iArray(3) = 4


Option Base 1
Dim vArray As Variant
vArray = VBA.Array(1, 2, 3, 4)
iArray(1) = 1
iArray(2) = 2
iArray(3) = 3
iArray(4) = 4

© 2017 Better Solutions Limited. All Rights Reserved. © 2017 Better Solutions Limited