用数组来保存产生的
随机数,每产生一个随机数就跟已经产生的随机数进行比较,如果跟已经产生的随机数中的一个相同的话就重新产生一个随机数,直到跟已经产生的所有随机数都不相同为止。
Private Sub Command1_Click()
Dim a(1 To 10) As Integer
Dim i As Integer
Dim j As Integer
Me.Cls
Randomize
For i = 1 To 10
Do
a(i) = Int(Rnd * 90) + 10
For j = 1 To i - 1
If a(i) = a(j) Then Exit For
Next
Loop While j < i
Print a(i);
Next
End Sub