reset and start

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JuAn2226
    New Member
    • Mar 2008
    • 27

    reset and start

    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.
  • kadghar
    Recognized Expert Top Contributor
    • Apr 2007
    • 1302

    #2
    Originally posted by JuAn2226
    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.
    lets say the array is called MyArr

    Erase MyArr

    will do

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      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

      • JuAn2226
        New Member
        • Mar 2008
        • 27

        #4
        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 coding

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by JuAn2226
          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 coding
          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?

          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

          Working...