任何在vb中产生绝对不重复随机数
来源:百度知道 编辑:UC知道 时间:2024/05/19 00:06:22
知道的朋友 请速度救命!!!!
产生10个1~100的数 绝对不重复的! 我要整个程序.
产生10个1~100的数 绝对不重复的! 我要整个程序.
那也得有个数的范围吧,要不然怎么做标记?
Private Sub Command1_Click()
Static num(10 To 100), c As Integer
For j = 10 To 100
num(j) = 0
Next j
Dim s, i
Randomize
For t = 1 To 10
begin:
s = Int(Rnd() * (100 - 10 + 1)) + 10
If num(s) <> 1 Then
num(s) = 1
Else
GoTo begin:
End If
Print s
Next t
End Sub
使用不重复的种子
randomize
dim s(10)
for i=1 to 10
s(i)=int(rnd*100)
b=b&s(i)&" "
next
msgbox b