When you want to use the values remember that collections start at 1 and not 0.VB Code:
Dim nTry As Integer Dim nAddCount As Integer Dim bFound As Integer Dim nDummy As Integer Dim MyCollection As New Collection Randomize Do Until nAddCount = 52 nTry = Int((52) * Rnd + 1) On Error Resume Next nDummy = MyCollection.Item(CStr(nTry)) bFound = (Err = 0) If bFound Then Err.Clear Else MyCollection.Add nTry, CStr(nTry) nAddCount = nAddCount + 1 End If Loop




Reply With Quote