Sub a()
Dim a As New Collection
Dim pa As Long
On Error GoTo err:
Randomize
For pa = 1 To 10000
temp = CInt(Rnd * 9) & CInt(Rnd * 9) & CInt(Rnd * 9) & CInt(Rnd * 9)
a.Add temp, "a" & temp
Next
err:
List1.AddItem pa
End Sub
Sub b()
Dim a As New Collection
Dim pa As Long
On Error GoTo err:
Randomize
For pa = 1 To 10000
temp = Format(CInt(Rnd * 99), "00") & Format(CInt(Rnd * 99), "00")
a.Add temp, "a" & temp
Next
err:
List2.AddItem pa
End Sub
Sub c()
Dim a As New Collection
Dim pa As Long
On Error GoTo err:
Randomize
For pa = 1 To 10000
temp = Format(CInt(Rnd * 9999), "0000")
a.Add temp, "a" & temp
Next
err:
List3.AddItem pa
End Sub
Private Sub Command1_Click()
List1.Clear
List2.Clear
List3.Clear
For i = 1 To 100
a
b
c
Next
MsgBox avg(List1) & vbCrLf & avg(List2) & vbCrLf & avg(List3)
End Sub
Function avg(ByVal lst As ListBox) As Long
avg = 0
For i = 0 To lst.ListCount - 1
avg = avg + Val(lst.List(i))
Next
avg = CLng(avg) / lst.ListCount
End Function