Erase (statement)

Syntax Erase array1 [,array2]...
Description Erases the elements of the specified arrays.
Comments For dynamic arrays, the elements are erased, and the array is redimensioned to have no dimensions (and therefore no elements). For fixed arrays, only the elements are erased; the array dimensions are not changed.
After a dynamic array is erased, the array will contain no elements and no dimensions. Thus, before the array can be used by your program, the dimensions must be reestablished using the Redim statement. Up to 32 parameters can be specified with the Erase statement.
The meaning of erasing an array element depends on the type of the element being erased:
Element Type What Erase Does to That Element
Integer Sets the element to 0.
Boolean Sets the element to FALSE.
Long Sets the element to 0.
Double Sets the element to 0.0.
Date Sets the element to December 30, 1899.
Single Sets the element to 0.0.
String (variable-length) Frees the string, then sets the element to a zero-length string.
String (fixed-length) Sets every character of each element to zero ( Chr$(0) ).
Object Decrements the reference count and sets the element to Nothing .
Variant Sets the element to Empty .
User-defined type Sets each structure element as a separate variable.
Example This example fills an array with a list of available disk drives, displays the list, erases the array and then redisplays the list.
Sub Main()
  Dim a$(10)  'Declare an array.
  DiskDrives a  'Fill element 1 with a list of available disk drives.
  r = SelectBox("Array Before Erase",,a)
  Erase a$    'Erase all elements in the array.
  r = SelectBox("Array After Erase",,a)
End Sub
See Also Redim (statement); Arrays (topic).