Erase

This statement reinitializes the elements of fixed-size arrays and deallocates dynamic-array storage space.

Syntax

Erase array

Parameters

array
Name of the array variable to be erased.

Remarks

It is important to know whether an array is fixed size (standard) or dynamic because Erase behaves differently depending on the type of array. For example, Erase recovers no memory for fixed-size arrays. The following table shows how Erase sets the elements of a fixed-size array.

Type of array
Effect of Erase on fixed-array elements
Fixed number array Sets each element to zero
Fixed string array Sets each element to zero-length ("")
Array of objects Sets each element to the special value Nothing

Erase frees the memory used by dynamic arrays. Before your application can refer to the dynamic array again, it must redeclare the dimensions of the array variable by using a ReDim statement.