Promotic

ReDim - statement of language VBScript

Description:
Used to declare dynamic-array variables and allocate or reallocate storage space.
Syntax:

ReDim [Preserve] name([dimensions])

Preserve Preserves the data in an existing array when you change the size of the last dimension.
name Name of the variable, follows standard variable naming conventions.
dimensions Dimensions of an array variable; up to 60 multiple dimensions may be declared.
The subscripts parameter uses the following syntax:
upper_index[, upper_index] ...
The lower array index is always zero.
Note:
The statement is used to size or resize a dynamic array that has already been formally declared using a Dim statement with empty parentheses (without dimension subscripts). The statement can be used repeatedly to change the number of elements and dimensions in an array.
 
If you use the Preserve keyword, then you can resize only the last array dimension, and you can't change the number of dimensions at all.
For example, if the array has only one dimension, then you can resize that dimension because it is the last and only dimension of the array.
However, if the array has two or more dimensions, then the size of only the last dimension can be changed and still preserve the contents of the array.
See also:
- Dim
- Set
Example:
The example shows how to increase the last dimension of dynamic array without deleting the data existing in the array.
VBScriptSelect and copy to clipboard

Dim X()
ReDim X(10, 10, 10)
ReDim Preserve X(10, 10, 15)

Caution: If an array after change is smaller than it was originally, then 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 empty string (""). Variables that refers to the 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.
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.