VBScript Reference Manual
InduSoft Web Studio
Declare dynamic array variables, and allocates or reallocates storage space at the procedural
ReDim [Preserve] varname(subscripts) [, varname(subscripts)]
Optional. Preserves the data in an existing array when you change the size of the single
dimension or the last dimension (only). If an array is contracted, data in the last elements will
still be lost. There is a high overhead associated with using the Preserve functionality and
should only be used when necessary.
Required, Name of the array variable, following standard variable naming conventions. Can
be any Variant subtype.
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 in VBScript since arrays are zero-based.
Returns a Variant containing an Array
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. Note that if you make an array smaller than
it was originally, data in the eliminated elements is lost.
A dynamic array must be declared without dimension subscripts.
‘ Declare a dynamic array
‘ Declares dynamic array variables
ReDim Preserve X(10,10,15)
‘ Change the size of the last dimension, preserving data
Rem (or) ‘
Includes explanatory remarks in a program
The comment argument is the text of any comment you want to include. After the Rem
keyword, a space is required before comment.
You can use an apostrophe (') instead of the Rem keyword. If the Rem keyword follows other
statements on a line, it must be separated from the statements by a colon. However, when you
use an apostrophe, the colon is not required after other statements.
myStr1 = “control” : Rem This is a comment after a statement, separated by a colon
myStr2 = “valve”
‘ This is also a comment but here, no colon is needed
Rem This is a comment line. No colon is needed