can anyone help me to to do coding for reset and start again. i got 10 array of random number, 10 array for start time how do i reset the both array after the 10 array is filled and start filling up again for new random number again.
reset and start
Collapse
X
-
lets say the array is called MyArrOriginally posted by JuAn2226can anyone help me to to do coding for reset and start again. i got 10 array of random number, 10 array for start time how do i reset the both array after the 10 array is filled and start filling up again for new random number again.
Erase MyArr
will do -
Be aware, though, that Erase will actually destroy the array so you can't use it again until you define it again (with Dim or whatever). If you just want to clear the values that are stored in the array, there are a number of things you could do. The simplest would be something like...
(assuming your array is numeric, and called MyArr())
[CODE=vb]Dim I As Long
For I = Lbound(MyArr) To Ubound(MyArr)
MyArr(I) = 0
Next
[/CODE]Comment
-
Thanks for the reply. i got problem here when after i reset. i have New set random number generated again. of coz the new set of random number can be exits in previous (before i reset) set of random number. how to check the new set of random with pervios set and discard if exits and generate new number again and check and store the number if it dint exits in previous set . Plz help me with the codingComment
-
So what you're saying is that when you produce another series of numbers, you want to ensure it doesn't include any that were in the prior set?Originally posted by JuAn2226Thanks for the reply. i got problem here when after i reset. i have New set random number generated again. of coz the new set of random number can be exits in previous (before i reset) set of random number. how to check the new set of random with pervios set and discard if exits and generate new number again and check and store the number if it dint exits in previous set . Plz help me with the coding
In that case I suppose you would need to have a second "backup" array where you keep a copy of the first one for checking. Each time you clear out your original array and fill it up, you check each new value against the backup array before adding it.
There's a sample program in the VB HowTo articles which produces a non-repeating series of random numbers. It may be of some help. Even if you can't use it, the code might be useful as examples of how some of the prcesses are done.
Just remember, there's almost always more than one way to accomplish a programming task. So the fact that somebody here wrote that code (hm... actually, I wrote that one!) doesn't mean you have to do the same thing.Comment
Comment