7,762
社区成员
发帖
与我相关
我的任务
分享
Dim ht As New Hashtable()
Dim i As Integer
Dim tmp As String
For i = 1 To 1000
tmp = Int(Rnd() * 10).ToString() '1000次循环产生10以内随机数,必然有大量的重复
If ht(tmp) = "" Then '查是否重复,如果不重复就插入,否则算了
ht.Add(tmp, tmp)
End If
Next
tmp = ""
For i = 0 To ht.Count - 1
tmp = tmp + ht.Values(i) + " "
Next
Dim ht As New Hashtable()
Dim i As Integer
Dim tmp As String
For i = 1 To 1000
Try
tmp = Int(Rnd() * 10).ToString() '1000次循环产生10以内随机数,必然有大量的重复
ht.Add(tmp, tmp)
Catch
End Try
Next
tmp = ""
For i = 0 To ht.Count - 1
tmp = tmp + ht.Values(i) + " "
Next