Erase Statement

The Erase Statement can be used to reinitialise arrays.
This statement can be used on both Fixed Size and Dynamic Size arrays although the behaviour is slightly different.
When you first declare a fixed-length string, it contains null characters.


Fixed Size Arrays

When used on a fixed array this statement will reset all the values to their default values.
No memory is recovered.


Dynamic Size Arrays

When used on a dynamic array this statement will actually erase all the items in the entire array.
If you want to use the array again you must use the ReDim statement to re-declare the size.
The memory will be recovered.


Numeric Arrays

Keeps the items and resets them all to zero.

Removes all the elements.


String Arrays

Values set to zero-length string in a variable array.
Values set to 0 in a fixed array.
Keeps the items and resets them all to empty string "".

Removes all the elements.

Keeps the items and resets them all to empty string "".

Removes all the elements.


Variant Arrays

Keep all the items and resets them all to Empty.

Removes all the elements.


Object Arrays

Keep all the items and resets them all to Nothing.

Removes all the elements.


Important

Fixed arrays keep their dimensions after erasing.
Dynamic arrays lose their dimensions after erasing.
The Erase statement cannot be used at class or module level. It can only be used inside a subroutine or function.
The Erase statement is equivalent to assigning the Nothing keyword to each array variable.


© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext