Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Empty an array 1

Status
Not open for further replies.

cainemart

Programmer
Nov 28, 2001
70
US
I have an array

Dim EPArray(1 To 9, 1 To 3, 2000 To 2003, 1 To 12, 1996 To 2003, 1 To 12, 1 To 5, 1 To 4) As Single

that loops through a file and collects the info. Well the array gets to large and give me a memory error. So I thought it would be best to use a counter and when it got to a certain number go into another process that dumps the arrays contents into another table. My problem is that I can't figure out how to start fresh with an empty array again. I have used Redim but it gave me an error about the array is already dimensioned. Then I tried Erase EPArray but there was info still in the array. I am using Win 00.

Does anyone have any suggestions?

Thanks
 
Cainemart...

Try

......
EPArray = Nothing
.....

This kills the array object from memory. You'll have to reintialize it, but it will free the resources if memory is the issue

 
The above does not work. You cannot assign "nothing" to an array. Does anyone else know how to reset an array (clear out all values and make length 0)?
 
you could make it a dinamic array which will allow you do do this...

Dim EPArray() As Single
...
ReDim EPArray(1 To 9, 1 To 3, 2000 To 2003, 1 To 12, 1996 To 2003, 1 To 12, 1 To 5, 1 To 4) As Single
...
' your code does it's thing and then needs to empty the array
' so...
ReDim EPArray(1 To 9, 1 To 3, 2000 To 2003, 1 To 12, 1996 To 2003, 1 To 12, 1 To 5, 1 To 4) As Single
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top