70
VBScript Reference Manual
InduSoft Web Studio
190
InduSoft, Ltd.
ReDim
Description
Declare dynamic array variables, and allocates or reallocates storage space at the procedural
level
Usage
ReDim [Preserve] varname(subscripts) [, varname(subscripts)]
)]
Arguments
Preserve
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.
varname
Required, Name of the array variable, following standard variable naming conventions. Can
be any Variant subtype.
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 in VBScript since arrays are zero-based.
Returns
Returns a Variant containing an Array
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
sion
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.
See also
Dim, Set
Example(s)
Dim X()
‘ Declare a dynamic array
ReDim X(10,10,10)
‘ Declares dynamic array variables
ReDim Preserve X(10,10,15)
‘ Change the size of the last dimension, preserving data
Rem (or) ‘
Description
Includes explanatory remarks in a program
Usage
Rem comment
or
‘ comment
Arguments
comment
The comment argument is the text of any comment you want to include. After the Rem
keyword, a space is required before comment.
Returns
N/A
Remarks
You can use an apostrophe (') instead of the Rem keyword. If the Rem keyword follows other
r
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.
Example
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