Option Explicit
Option Base 1
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Const Nums = 10
Private Sub Command1_Click()
Dim t As Long
Dim Num(Nums) As Long
Dim i, n As Long
Dim s As String
t = timeGetTime
Randomize
For i = 1 To Nums
n = Int(Rnd * Nums) + 1
If Num(n) = 0 Then
Num(n) = n
s = s & n & ","
Else
i = i - 1 '比较妙
End If
Next i
Text1.Text = s
t = timeGetTime - t
MsgBox t
End Sub