| << D.4.1- Unsupported Date Functions and Statements | AppendixD | D.5.0- Unsupported Array functions and Statements >> |
Array Functions and Statements
One major difference between VB/VBA and VBScript is the way you can declare your arrays. VBScript does not support the Option Base statement and you cannot declare arrays that are not zero-based. Below is a list of functions and statements that you can use for array manipulation in VBScript.
|
Array |
Returns a comma-delimited list of values as a Variant subtype Array (8192).
|
|
Syntax
|
Array(arglist)
arglist is a comma-delimited list of values that is inserted into the one dimensional array in the order they appear in the list
|
|
Note
|
An array of zero length is created if arglist contains no arguments. All arrays in VBScript are zero-based, which means that the first element in the list will be element 0 in the returned array.
|
|
Example |
Dim arrstrTest arrstrTest = Array( _
MsgBox displays Element0
|
|
See Also |
Dim |
|
Erase |
Reinitializes the elements if it is a fixed-size array and de-allocates the memory used if it is a dynamic array.
|
|
Syntax
|
Erase array
array is the array to be reinitialized or erased.
|
|
Note
|
|
|
Example |
Dim
arrstrDynamic()
|
|
See Also |
Dim and ReDim |
|
For Each |
Performs a group of statements repeatedly for each element in a collection or an array.
|
|
Syntax
|
For Each element In group [statements] [Exit For] Next [element]
element is a variable used for iterating
through the elements in a collection or an array.
|
|
Note
|
|
|
Example |
Dim arrstrLoop |
|
IsArray |
Returns a Variant subtype Boolean
(11) indicating if a variable is
|
|
Syntax
|
IsArray(varname)
varname is a variable you want to check is an array.
|
|
Note
|
|
|
Example |
Dim strName
|
|
See Also |
IsDate, IsEmpty, IsNull, IsNumeric, IsObject and VarType |
|
LBound |
Returns the smallest possible subscript for the dimension indicated.
|
|
Syntax
|
LBound(arrayname[, dimension])
arrayname is the name of the array variable.
|
|
Note
|
|
|
Example |
Dim arrstrFixed(3)
MsgBox displays 0.
|
|
See Also |
Dim, ReDim and UBound |
|
ReDim |
|
|
Syntax
|
ReDim [Preserve] varname(subscripts[, varname(subscripts)]...)
Preserve
(Optional) is used to preserve the data in an existing array, when you resize
it. The overhead of using this functionality
varname is the name of the array variable. upper[, upper]... where you indicate the upper bounds of the subscript. The lower bound is always zero.
|
|
Note
|
|
|
Example |
Dim
arrstrDynamic() ' Resize the array, but
MsgBox displays 3.
|
|
See Also |
Dim and Set |
|
UBound |
Returns the largest possible subscript for the dimension indicated
|
|
Syntax
|
UBound(arrayname[, dimension])
arrayname is the name of the array variable.
|
|
Note
|
|
|
Example |
Dim arrstrFixed(3)
MsgBox UBound(arrstrFixed)
MsgBox displays 3.
|
|
See Also |
Dim statement, UBound and ReDim statement |
| << D.4.1- Unsupported Date Functions and Statements | AppendixD | D.5.0- Unsupported Array functions and Statements >> |

RSS
