Dim a() As Integer 'a是用来存放生成的n个随机正整数
Private Sub Command1_Click()
n = InputBox("请输入一个正整数n,n>=1")
ReDim a(1 To n)
Dim p As String 'p表示随机生成的n个整数
Randomize
p = ""
For i = 1 To n '生成n个整数
Do
x = Int(Rnd * 90) + 10 '存放中间生成的一个随机数,范围是0到99,包括0也包括99
yes = 0 '用来判断生成的x要还是不要,0表示要,1表示不要
For j = 1 To i - 1 '对要生成的第i个速技术进行检测,检测结果放在yes中
If x = a(j) Then yes = 1: Exit For
Next
Loop While yes = 1
a(i) = x
p = p & Str(a(i)) & ","
Next
Label1.Caption = LTrim(Left(p, Len(p) - 1)) '用label1显示最终的随机生成的n个随机整数
End Sub