Siebel VB Language Reference > Siebel VB Language Reference >

Erase Statement


This standard VB statement reinitializes the contents of a fixed array or frees the storage associated with a dynamic array.

Syntax

Erase Array[, Array]

Argument
Description
Array
The name of the array variable to re-initialize

Returns

Not applicable

Usage

The effect of using Erase on the elements of a fixed array varies with the type of the element:

Element Type
Erase Effect
Numeric
Each element is set to zero.
Variable-length string
Each element is set to a zero-length string ("").
Fixed-length string
Each element's string is filled with zeros.
Variant
Each element is set to Empty.
User-defined type
Members of each element are cleared as if the members were array elements; that is, numeric members have their values set to zero, the strings to "", and so on.
Object
Each element is set to the special value Nothing.

Example

This example prompts for a list of item numbers to put into an array and clears the array if the user wants to start over.

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

See Also

Dim Statement
LBound Function
ReDim Statement
UBound Function


 Siebel VB Language Reference
 Published: 18 June 2003