Erase statement
Reinitialize the elements of a fixed-size array and release the storage space for the dynamic array.
Erase array
The array parameter is the name of the array variable to clear.
Description
It is important to determine whether an array is a fixed-length array (regular) or a dynamic array, because Erase to perform different operations based on the type of the array. Erase eliminates the need to restore memory for fixed-size arrays. Erase Sets the elements of a fixed array according to the following table:
type of array | The
effect of Erase on fixed array elements |
Fixed numeric array |
Set each element to 0. |
Fixed string array |
Set each element to a zero-length string (""). |
Array of objects |
Set each element to a special value of nothing. |
Erase frees the memory used by the dynamic array. Before the program references the dynamic array again, you must use the ReDim statement to redefine the dimension of the array variable.
The following example illustrates how to use the Erase statement.
Dim NumArray(9) Dim DynamicArray()ReDim DynamicArray(9) '
Allocate storage space. Erase NumArray '
each element is reinitialized. Erase DynamicArray '
frees the memory occupied by the array.