Option Explicit
Dim Card_Number(1 To 52) As Integer
Dim Deck(1 To 52) As String
Private Sub Setup_Deck()
Deck(1) = "A-S"
Deck(2) = "2-S"
Deck(3) = "3-S"
Deck(4) = "4-S"
Deck(5) = "5-S"
Deck(6) = "6-S"
Deck(7) = "7-S"
Deck(8) = "8-S"
Deck(9) = "9-S"
Deck(10) = "10-S"
Deck(11) = "J-S"
Deck(12) = "Q-S"
Deck(13) = "K-S"
Deck(14) = "A-C"
Deck(15) = "2-C"
Deck(16) = "3-C"
Deck(17) = "4-C"
Deck(18) = "5-C"
Deck(19) = "6-C"
Deck(20) = "7-C"
Deck(21) = "8-C"
Deck(22) = "9-C"
Deck(23) = "10-C"
Deck(24) = "J-C"
Deck(25) = "Q-C"
Deck(26) = "K-C"
Deck(27) = "A-D"
Deck(28) = "2-D"
Deck(29) = "3-D"
Deck(30) = "4-D"
Deck(31) = "5-D"
Deck(32) = "6-D"
Deck(33) = "7-D"
Deck(34) = "8-D"
Deck(35) = "9-D"
Deck(36) = "10-D"
Deck(37) = "J-D"
Deck(38) = "Q-D"
Deck(39) = "K-D"
Deck(40) = "A-H"
Deck(41) = "2-H"
Deck(42) = "3-H"
Deck(43) = "4-H"
Deck(44) = "5-H"
Deck(45) = "6-H"
Deck(46) = "7-H"
Deck(47) = "8-H"
Deck(48) = "9-H"
Deck(49) = "10-H"
Deck(50) = "J-H"
Deck(51) = "Q-H"
Deck(52) = "K-H"
End Sub
Private Sub ShuffleCard_Number()
Dim CardCount As Integer 'This will be my loop counter
Dim CardVal As Integer 'This will get assigned the random value
CardCount = 1 'Resets card count to 1
Do While CardCount < 53 'This sets every slot in Card_Number to -1
Card_Number(CardCount) = -1 'so that later I can tell if the slot is empty
CardCount = CardCount + 1 'or not
Loop
CardCount = 1 'Resets card count to 1
Do While CardCount < 53 'Loop until every slot is full
10 CardVal = Int((52 * Rnd) + 1) 'Set CardVal = to a random number
If Card_Number(CardVal) = -1 Then 'Take random slot and see if there is a card
'in it yet. If there isn't it will be = to -1
'if there is it will be equal to a different
'value.
Card_Number(CardVal) = CardCount 'There isn't so put current card in that slot
CardCount = CardCount + 1 'Increment my card count
Else: GoTo 10 'There is so start again from the beginning
End If
Loop 'Do it all again if < 53
End Sub
Private Sub Command1_Click()
Me.Cls
ShuffleCard_Number
Print Deck(Card_Number(1)), Deck(Card_Number(2)), Deck(Card_Number(3)), Deck(Card_Number(4)), Deck(Card_Number(5))
End Sub
Private Sub Form_Load()
Me.Show
Me.AutoRedraw = True
Randomize
Setup_Deck
End Sub