Erase statement
Reinitialize elements of a fixed-size array and free up storage space for dynamic arrays.
Erase array
arrayThe parameter is the name of the array variable to be cleared.
illustrate
It is important to determine whether an array is a fixed-length array (regular) or a dynamic array, becauseEraseDifferent operations should be performed according to the type of the array.EraseNo need to restore memory for fixed-sized arrays.EraseSet the elements of the fixed array according to the following table:
Type of array | The effect of Erase on fixed array elements |
---|---|
Fixed array of numeric values | Set each element to 0. |
Fixed string array | Sets each element to a zero-length string (""). |
Object array | Set each element to a special value Nothing. |
EraseFrees up the memory used by the dynamic array. Before the program references the dynamic array again, it must be usedReDimStatement to redefine the dimensions of the array variable.
The following example shows how to use itEraseStatement.
Dim NumArray(9) Dim DynamicArray()ReDim DynamicArray(9) '
Allocate storage space。Erase NumArray '
Each element is reinitialized。Erase DynamicArray '
Free the memory occupied by the array。