|
-
Feb 2nd, 2003, 10:12 AM
#1
Thread Starter
Fanatic Member
Clearing an integer array... what value should be used? [SOLVED]
I know you need to loop through the array, I just need to know what value I should set each element in the array to. The name I used for the array is arrNum40, which has 40 elements.
Last edited by hothead; Feb 2nd, 2003 at 02:56 PM.
-
Feb 2nd, 2003, 11:05 AM
#2
What kind of array. If it is only one of the common used datatypes you don't have to clear them out before ending your app if that is what you are thinking of. But if it is an array of objects then you should set them to "Nothing"
like:
-
Feb 2nd, 2003, 12:05 PM
#3
Thread Starter
Fanatic Member
It's an integer array. Actually I was thinking about making a game with 3 rounds, and after each round is over, it clears the array and starts the new round.
-
Feb 2nd, 2003, 01:16 PM
#4
Thenjust give them value 0...or something....
-
Feb 2nd, 2003, 02:16 PM
#5
I could be wrong but->
wouldn't you just use the following line of code?
Erase arrNum40
-
Feb 2nd, 2003, 02:40 PM
#6
Ex-Super Mod'rater
That would free the memory being used tho and resize it to zero elements, so he would need to re-initialise it aswell. Mind if its going to be a different size or is very big I guess it would be better, as long as he is wanting to clear all elements.
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
Feb 2nd, 2003, 02:43 PM
#7
Thread Starter
Fanatic Member
I wrote a function that re-initializes it automatically using ReDim Preserve, so that won't be a problem. Thanks for the info.
-
Feb 3rd, 2003, 10:11 AM
#8
Erase->
If Erase would reset arrays to zero elements, this
code shouldn't work right?
Dim TestArray(10)
Debug.Print TestArray(5)
Erase TestArray
Debug.Print TestArray(5)
Erase doesn't seem to reset the array to zero
elements but simply clear the elements.
-
Feb 3rd, 2003, 10:14 AM
#9
Re: Erase->
Originally posted by Peter Swinkels
If Erase would reset arrays to zero elements, this
code shouldn't work right?
Dim TestArray(10)
Debug.Print TestArray(5)
Erase TestArray
Debug.Print TestArray(5)
Erase doesn't seem to reset the array to zero
elements but simply clear the elements.
Dynamic arrays are cleared - you have to ReDim 'em. So your second example wouldn't work if your array was dynamic.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|