用VB随机生成N个不重复的二位数

来源:百度知道 编辑:UC知道 时间:2024/06/13 16:35:16

用到
一个TextBox1(用来输入你要的N)

一个Label1(用来输出生成的数据)

Dim i, j, lowB, highB, tmpNum As Integer
dim n As Integer
Dim myArray() As Integer
Dim notRe As Boolean

i = 0
j = 0
lowB = 10
highB = 99
notRe = False

n = CInt(TextBox1.text)
Label1.Text = ""

Randomize()

For i = 0 To n - 1
notRe = False
Do While (notRe = False)
notRe = True
myArray(i) = Int((highB - lowB + 1) * Rnd() + lowB)
If Not i = 0 Then
For j = 0 To i - 1
If myArray(i) = myArray(j) Then notRe = False
Next
End If
Loop
Label1.Text = Label1.Text & myArray(i) & " "
Next

随机产生【a