Sun Chili!Soft ASP Sun Chili!Soft
ASP Sun Microsystems

 

VBScript Erase Statement

Reinitializes the elements of fixed-size arrays and deallocates dynamic-array storage space.

Syntax: VBScript Erase Statement

Erase array

Arguments: VBScript Erase Statement

array

The name of the array variable to be erased.

Remarks: VBScript Erase Statement

It is important to know whether an array is fixed-size (ordinary) or dynamic because Erase behaves differently depending on the type of array. Erase recovers no memory for fixed-size arrays. Erase sets the elements of a fixed array as follows:

Type of array

Effect of Erase on fixed-array elements

Fixed numeric 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 program can refer to the dynamic array again, it must redeclare the array variable's dimensions using a ReDim statement.

The following example illustrates the use of the Erase statement.

Dim NumArray(9)

Dim DynamicArray()

ReDim DynamicArray(9)   ' Allocate storage space.

Erase NumArray   ' Each element is reinitialized.

Erase DynamicArray   ' Free memory used by array.

Copyright 2002 Sun Microsystems, Inc. All rights reserved. Legal Notice.