Results 1 to 2 of 2

Thread: Shuffle Cards

Threaded View

  1. #2
    New Member
    Join Date
    May 2001
    Location
    Colorado
    Posts
    11
    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.

    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
    Hope this helps.
    Last edited by TMTOMH; May 16th, 2001 at 09:41 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width