How do I set an array to nothing?
I have tried to set an array to nothing but it doesn't work.
MyArray = nothing
What's the proper way?
Appreciate it.
[140 byte] By [
nbCathy] at [2007-11-19 1:59:44]

# 1 Re: How do I set an array to nothing?
How about REDIM without the Preserve keyword? Won't set to nothing, but should be able to release the memory used.
# 2 Re: How do I set an array to nothing?
Looking through the help files, it looks like you could use the ERASE keyword.
Reinitializes the elements of fixed-sizearrays and releases dynamic-array storage space.
Syntax
Erase arraylist
The required arraylistargument is one or more comma-delimited arrayvariables to be erased.
Remarks
Erase behaves differently depending on whether an array is fixed-size (ordinary) or dynamic. 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 (variable length) Sets each element to a zero-length string ("").
Fixed string array (fixed length) Sets each element to zero.
FixedVariant array Sets each element toEmpty.
Array ofuser-defined types Sets each element as if it were a separate variable.
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.
# 3 Re: How do I set an array to nothing?
Looking through the help files, it looks like you could use the ERASE keyword.
From Help:
Reinitializes the elements of fixed-sizearrays and releases dynamic-array storage space.
Syntax
Erase arraylist
The required arraylistargument is one or more comma-delimited arrayvariables to be erased.
Remarks
Erase behaves differently depending on whether an array is fixed-size (ordinary) or dynamic. 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 (variable length) Sets each element to a zero-length string ("").
Fixed string array (fixed length) Sets each element to zero.
FixedVariant array Sets each element toEmpty.
Array ofuser-defined types Sets each element as if it were a separate variable.
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.
# 4 Re: How do I set an array to nothing?
Looks like I have to use ERASE because the array is a Fixed Array. I tried the ReDim and it didn't work.
Thanks ya'll