When working with arrays you can always use the LBOUND (low boundary) and UBOUND (Upper Boundary) Functions.

Here is lbound

Description

Returns the smallest available subscript for the indicated dimension of an array.

Syntax

LBound(arrayname[, dimension])

The LBound function syntax has these parts:

Part Description

arrayname Name of the array variable; follows standard variable naming conventions.

dimension Whole number indicating which dimension’s lower bound is returned. Use 1 for the first dimension, 2 for the second, and so on. If dimension is omitted, 1 is assumed.

Remarks

The LBound function is used with the UBound function to determine the size of an array. Use the UBound function to find the upper limit of an array dimension.

The lower bound for any dimension is always 0.

Here is ubound

Description

Returns the largest available subscript for the indicated dimension of an array.

Syntax

UBound(arrayname[, dimension])

The UBound function syntax has these parts:

Part Description

arrayname Required. Name of the array variable; follows standard variable naming conventions.

dimension Optional. Whole number indicating which dimension’s upper bound is returned. Use 1 for the first dimension, 2 for the second, and so on. If dimension is omitted, 1 is assumed.

Remarks

The UBound function is used with the LBound function to determine the size of an array. Use the LBound function to find the lower limit of an array dimension.

The lower bound for any dimension is always 0. As a result, UBound returns the following values for an array with these dimensions:

Dim A(100,3,4)

Statement Return Value

UBound(A, 1) 100

UBound(A, 2) 3

UBound(A, 3) 4

Then to add to it you just use the redim statement with the PRESERVE keyword.

Here is the help for REDIM

Description

Declares dynamic-array variables, and allocates or reallocates storage space at procedure level.

Syntax

ReDim [Preserve] varname(subscripts) [, varname(subscripts)] . . .

The ReDim statement syntax has these parts:

Part Description

Preserve Preserves the data in an existing array when you change the size of the last dimension.

varname Name of the variable; follows standard variable naming conventions.

subscripts Dimensions of an array variable; up to 60 multiple dimensions may be declared. The subscripts argument uses the following syntax:

upper [,upper] . . .

The lower bound of an array is always zero.

Remarks

The ReDim statement is used to size or resize a dynamic array that has already been formally declared using a Private, Public, or Dim statement with empty parentheses (without dimension subscripts). You can use the ReDim statement repeatedly to change the number of elements and dimensions in an array.

If you use the Preserve keyword, you can resize only the last array dimension, and you can’t change the number of dimensions at all. For example, if your array has only one dimension, you can resize that dimension because it is the last and only dimension. However, if your array has two or more dimensions, you can change the size of only the last dimension and still preserve the contents of the array.

The following example shows how you can increase the size of the last dimension of a dynamic array without erasing any existing data contained in the array.

ReDim X(10, 10, 10)

. . .

ReDim Preserve X(10, 10, 15)

Caution If you make an array smaller than it was originally, data in the eliminated elements is lost.

When variables are initialized, a numeric variable is initialized to 0 and a string variable is initialized to a zero-length string (“”). A variable that refers to an object must be assigned an existing object using the Set statement before it can be used. Until it is assigned an object, the declared object variable has the special value Nothing.

You can download the complete reference from http://msdn.microsoft.com/scripting/. You might think about grabbing the Jscript reference also. Note that neither of these references expose object declared by either the Browser or ASP as these are not part of the actual scripting languages.

Wayne Luke

WR Moderator

Internet Media Provider