Erase Array Method
The Erase Array method erases the contents of a fixed array or frees the storage associated with a dynamic array. It does not return a value. The following table describes how it erases the contents of different element types.
Element Type | Description |
---|---|
Numeric |
Sets each element to zero. |
Variable-length string |
Sets each element to a zero-length string (""). |
Fixed-length string |
Fills the string of each element with zeros. |
Variant |
Sets each element to Empty. |
Custom type |
Clears each member of each element as if each member is an array element. For example, it sets numeric members to zero, strings to "", and so on. |
Object |
Sets each element to the following value: Nothing |
Format
Erase Array[, Array]
The following table describes the arguments that you can use with this method.
Argument | Description |
---|---|
Array |
The name of the array to erase. |
Example
The following example prompts the user for a list of item numbers to put into an array. If the user must start over, then it clears the array. For information about the Dim statement, see Declare Variable Statement:
Sub Button_Click
Dim msgtext
Dim inum(100) as Integer
Dim x, count
Dim newline
newline = Chr(10)
x = 1
count = x
inum(x) = 0
Do
inum(x) = x + 1
If inum(x) = 99 then
Erase inum()
x = 0
ElseIf inum(x) = 0 then
Exit Do
End If
x = x + 1
Loop
count = x-1
msgtext = "You entered the following numbers:" & newline
For x = 1 to count
TheApplication.TraceOn "c:\temp\trace.txt", "Allocation", "All"
TheApplication.Trace msgtext & inum(x) & newline
Next x
End Sub