Description:
Reinitializes items of fixed-size array and deallocates dynamic-array storage space.
Syntax:
Erase array
The array parameter is the name of the array variable to be erased.
Note:
It is important to know whether an array is fixed-size (ordinary) or dynamic because statement behaves differently depending on the type of array.
Erase recovers no memory for fixed-size arrays.
Erase sets items of a fixed array as follows:
Type of array |
Effect of Erase on fixed-array elements |
Fixed numeric array |
Sets each item to zero. |
Fixed string array |
Sets each item to empty string (""). |
objects |
Sets each item to the Nothing value |
Erase frees the memory used by dynamic arrays. Before your program can refer to the dynamic array again, it must redeclare the array variable's dimensions using a
ReDim statement.
Example:
VBScriptSelect and copy to clipboard
Dim numArray(
9), dynArray()
ReDim dynArray(9)
' Allocate storage space
Erase numArray
' All items are reinitialized
Erase dynArray
' Free memory used by array