Dim a() As Integer 'n显示随机正整数
Private Sub Command1_Click()
n = InputBox("请输入一个正整数n,n>=1") 'n用来储存正整数
Call getNinteger(n)
End Sub
Sub getNinteger(ByVal n As Integer)
ReDim a(1 To n) 'p用来显示随即生成的n个数
Dim p As String
Randomize
p = ""
For i = 1 To n
Do
x = Int(Rnd * 90) + 10 'x是随机生成的正整数
yes = 0
For j = 1 To i - 1 '用来判断生成的正整数是否可取
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))
End Sub