It comes out like this:
Code:1. Dim colRandom As New Collection 2. Dim intTry As Integer 3. 4. Randomize 5. 6. On Error Resume Next 7. 8. Do Until colRandom.Count = 6 9. ' Generate the random number 10. intTry = Int(Rnd * 16 + 1) 11. ' Attempt To add it To the collection along with a matching key 12. colRandom.Add intTry, CStr(intTry) 13. If Err.Number = 457 Then 14. ' The key is already In the collection so it isn't added again 15. End If 16. Loop 17. 18. For intTry = 1 To 6 19. Debug.Print colRandom(intTry) 20. Next




Reply With Quote