Clearing an Array...

  • Thread starter Thread starter Gary
  • Start date Start date
G

Gary

Hi

How does one clear an Array?

Situation is when I am executing my program everything works fine, but when
I try and repeat the program without resetting my program I get this error,
'System.IndexOutOfRangeException' , does this mean I have to somewhere
reset/clear my array before I can re-execute my program?.


thanks,

Gary
 
Gary said:
How does one clear an Array?

You can do so by a ReDim:

ReDim Preserve ProjArray(12, 0)

or a simple "erase"

Erase ProjArray
I try and repeat the program without resetting my program I get this error,
'System.IndexOutOfRangeException' , does this mean I have to somewhere
reset/clear my array before I can re-execute my program?.

This is probably because you tried to change the size of the Array?

Thus if ProjArray(12, 0) tries to add ProjArray(13, 0), you'll get an error,
unless you ReDim it to ProjArray(13, 0)

Regards,

Bruce
 
It is clear that you're trying to index past the bounds of the array...but
the only way to find out why is to see some code. Can you elaborate on what
you're doing with the array when this happens or post a code snippet?

ShaneB
 
thanks guys for replying so quick to my message.

yes that was my next step to post the code, but as it turns out I sorted it
out for myself and I was trying to pass the bounds of the index! so at the
end of the event all I had to do was to reset the index, x = 1

Thanks again

Gary
 
Back
Top