Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Array Function

Updated: April 2009

Returns a Variant containing an array.


                      Array(
                      arglist
                      )
                    

The required arglist argument is a comma-delimited list of values that are assigned to the elements of an array contained with the Variant. If no arguments are specified, an array of zero length is created.

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.

All arrays in Visual Basic Scripting Edition (VBScript) are zero-based.

The Array function is used to create single-dimension arrays. For information about multi-dimensional arrays, see VBScript Variables.

Note Note:

A variable that is not declared as an array can still contain an array. Although a Variant variable containing an array is conceptually different from an array variable containing Variant elements, the array elements are accessed in the same way.

The following example illustrates the use of the Array function.

' Create a single-dimension array and assign three elements.
Dim A
A = Array(10,20,30)
' Set B to the third element in the array (which is 30).
' The array is zero-based.
B = A(2)

Date

History

Reason

April 2009

Added information to remarks and added comments to the example.

Customer feedback.

Community Additions

Show:
© 2015 Microsoft