Kel,
Here's how I did it and I've seen others use the same technique. It seems to work pretty well and it's a little bit cleaner than generating the random numbers and throwing out the ones you've already used. My deck has optional Jokers so If you're not using jokers, the StyleOfGame stuff can be removed and just use "52 To 1" for the inner For loop.
Hope this helps.Code:Sub Shuffle(Deck() As Integer) Randomize Timer For I = 1 To 10 ' Styleofgame has a value of either 0 or 1. ' When it's 0, we will only shuffle the first ' 52 cards. if it's 1, we'll do all 54. For J = (52 + Styleofgame * 2) To 1 Step -1 randindex = Int(J * Rnd + 1) Temp = Deck(J) Deck(J) = Deck(randindex) Deck(randindex) = Temp Next J Next I End Sub




Reply With Quote