I was actually talking about the shuffle loop:
VB Code:
Do While mcolDeck.Count < 52
intCard = Int(52 * Rnd + 1)
On Error Resume Next
mcolDeck.Add CStr(intCard), CStr(intCard)
Loop
Although longer, these probably turn out to be less lines of executed code:
VB Code:
' mColDeck is populated once (Form_Load or whereever) and then shuffled from the existing pack
Private Sub Shuffle()
Dim colTemp As Collection
Dim intCard As Integer
Randomize
Set colTemp = New Collection
Do While mcolDeck.Count
intCard = Int((mcolDeck.Count - 1) * Rnd + 1)
colTemp.Add mcolDeck(intCard)
mcolDeck.Remove intCard
Loop
Set mcolDeck = Nothing
For intCard = 1 To colTemp.Count
mcolDeck.Add colTemp(intCard)
Next intCard
Set colTemp = Nothing
End Sub
' or repopulating each time:
Private Sub Shuffle()
Dim colTemp As Collection
Dim intCard As Integer
Randomize
Set colTemp = New Collection
Set mcolDeck = Nothing
For intCard = 1 To 52
colTemp.Add Cstr(intCard)
Next intCard
Do While colTemp.Count
intCard = Int((colTemp.Count - 1) * Rnd + 1)
mcolDeck .Add colTemp(intCard)
colTemp.Remove intCard
Loop
Set colTemp = Nothing
End Sub
(I've just written those two out, so apologies if there's any errors)