要随机生成不重复的随机数,我写的代码总是有重复的,请高手指点!
我写了两段帐号自动生成的代码如下,可是会有很多重复的,如何才能让他不重复?麻烦帮我看一下如何修改?
<%
Function RndNumber(Min,Max)
Randomize
RndNumber=Int((Max - Min + 1) * Rnd() + Min)
End Function
for i=0 to 1000
for i2=0 to 0
num=RndNumber(100000000,999999999)
response.Write(num)
next
response.Write("<br>")
next
%>
还有一段是生成字母与数字混合的帐号,都是有相同帐号的
<%
Function Createpass(LengthNum)
Dim Ran,i
if Not IsNumeric(LengthNum) then LengthNum=8
Createpass=""
For i2=1 To LengthNum
Randomize
Ran = CInt(Rnd * 2)
Randomize
If Ran = 0 Then
Ran = CInt(Rnd * 25) + 97
Createpass =Createpass& UCase(Chr(Ran))
ElseIf Ran = 1 Then
Ran = CInt(Rnd * 9)
Createpass = Createpass & Ran
ElseIf Ran = 2 Then
Ran = CInt(Rnd * 25) + 97
Createpass =Createpass& Chr(Ran)
End If
Next
End Function
dim num
for i=0 to 100
for i2=0 to 0
num=Createpass(8)
response.Write(num)
next
response.Write("<br>")
next
%>