Dimensional Arrays archives - The VBScript Network and Systems Administrator's Cafe

The VBScript Network and Systems Administrator's Cafe:

dimensional arrays

Aug 17 2008   2:02AM GMT

VBScript Statements: Explanation of the ReDim Statement



Posted by: Jerry Lees
arrays, VBScript Statements, dimensional arrays, redim

The ReDim statement in VBScript allows you to declare a array, or a multi-dimensional array, in your code. Also, this statement allows you to re-declare the number of elements in the array at a later time in the code.

This is important because it also allows you to release memory or allocate more memory for use in your script.

As you use this statement, be sure to use the Preserve keyword if you wish to preserve the existing data in the array.

Below are examples:

Dim x(10)
ReDim x(15)

Jun 20 2008   3:19PM GMT

VBScript Statements: Explanation of the Erase statement



Posted by: Jerry Lees
VBScript, VBScript Statements, vbscriptstatements, erase, working with arrays, dimensional arrays

The VBScript Erase statement is used to erase all the values of an array, but keep the array size and dimensions intact.

 This is useful when you re-use an array and you want to ensure the values inside an array have truely been cleared and no old data is left in the array.

For example, the following would print a blank line:

Redim Bob(10)
Bob(1) = “Rickky Bobby”
Erase Bob
Wscript.echo Bob(1)