Private Sub Command1_Click()
'I haven't written this for speed or efficiency, although the ShuffleDeck algorithm is as fast as it gets :D
Dim i As Long
Dim j As Long
Dim k As Long
Dim x As Long
Dim msg As String
Dim Cards(0 To 51) As Long '52 cards
Dim Counter As Long
'assign cards a number
For i = 0 To 51
Cards(i) = i
Next i
Randomize
'gather stats
For j = 1 To 10000
GoSub ShuffleDeck 'select the cards
'now all 52 cards are in random order, the one in offset 51 is the first card chosen.
'so if we choose a random card between card zero and the penultimate card
'(conveniently ignoring the first chosen card), then we can get an average probability
'of a spade turning up
x = Cards(51 * Rnd) \ 13 'choose second card (from range 0 to 50) and decide what suit its from
If x = 0 Then Counter = Counter + 1 'if its a spade then tally it
Next j
MsgBox "SPADES occur at a prob of: " & (Counter / 10000)
Exit Sub
'#########
ShuffleDeck:
For i = 51 To 0 Step -1
x = Rnd * i 'will round down to the nearest long value :) and neatly avoids returning i
k = Cards(i)
Cards(i) = Cards(x)
Cards(x) = k
Next i
Return
'#########
End Sub