ARRAY(arglist)

Returns an array containing the given values (Variant).


arglistThe comma separated 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.
* For the Microsoft documentation refer to docs.microsoft.com

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

© 2019 Better Solutions Limited. All Rights Reserved. © 2019 Better Solutions Limited Top