We understood what you typed, but you don't understand random numbers.
'random' means that you have an equal chance every time of picking any number. That means, just because 13 came up last time, does not mean it cannot come up again.
What you and jjortiz want is a deck shuffle algorithm, maybe with a 'deck' of, say 1000 cards. In this case each card is the 'random' (by your definition) number you want to return. That way, the number you get is never repeated.
Put an array of sequential numbers in random order:
Code:Option Explicit Option base 1 Dim where as Integer ' public pointer or number picker Dim limit as Integer ' this is the upper limit you got from the user Dim arr() as Integer ' deck of unique numbers in random order Sub bldDeck() Dim tmp as integer Dim i as integer Dim j as integer Redim arr(limit) where = 0 ' set the number picker to the beginning for i = 1 to limit arr(i) = i next ' we now have a bunch of non-repeating,sequential numbers ' now put them in random order j = limit Do While j > 1 i = (rnd*j) +1 ' pick a number at random tmp = arr(i) arr(i) = arr(j) arr(j) = tmp ' the two numbers are swapped j = j -1 ' make the list one element shorter Loop ' you now have limit numbers in random order End Sub Function getNum() as Integer where = where + 1 getNum = arr(where) ' this is a randomly ordered number ' from 1 to limit End Function




Reply With Quote