Previous Topic

Next Topic

ReDim statement

The ReDim statement is used to size or resize a dynamic array formally declared using a Dim statement.

Syntax

ReDim [Preserve] varname(subscript) [AS type] [,varname(subscript) [AA type]]

Used at procedure level to reallocate storage space for dynamic array variables.

Part

Description

Preserve

Optional. keyword used to preserve the data in an existing array when you change the size.

Varname

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

Subscripts

Required. The subscripts argument uses the following syntax: [lower To] upper.
When not explicitly stated in lower, the lower bound of an array defaults to 1.

Type

Optional. Data type of the variable; as per Dim statement.

Notes

You can use the ReDim statement repeatedly to change the number of elements and dimensions in an array.

If you make an array smaller than it was, data in the eliminated elements will be lost.

When variables are initialised, a numeric variable is initialised to 0, a variable-length string is initialised to a zero-length string (""). Variant variables are initialised to Empty. Each element of a User-defined type variable is initialised as if it were a separate variable. A variable that refers to an object must be assigned an existing object before it can be used. Until it is assigned an object, the declared object variable has the special value Nothing, which indicates that it doesn't refer to an instance of an object.

See Also

MaxBasic Statements

Book Contents

Book Index