ASP generated random number:
Copy Code code as follows:
Randomize ' pure random, not repetitive
Response.Write Int ((999999999 * Rnd) + 111111111) ' generates random numbers from 111111111 to 999999999
ASP does not repeat random numbers:
Method One: Measured
Use the time to notice the character of the split string inside.
Copy Code code as follows:
<%
' generates an array that is not duplicated.
Function Getrnd (Lowernum,uppernum)
Dim unit,rndnum,fun_x
Unit = Uppernum-lowernum
Redim myarray (unit)
For fun_i=0 to Unit
MyArray (fun_i) = Lowernum + Fun_i
Next
For Fun_i=0 to round (unit)
Rndnum = Getrndnumber (fun_i,unit)
fun_x = MyArray (rndnum)
MyArray (Rndnum) =myarray (fun_i)
MyArray (Fun_i) =fun_x
Next
Getrnd = Join (myarray)
End Function
Function Getrndnumber (Lowerbound,upperbound)
Randomize
Getrndnumber=int ((upperbound-lowerbound+1) *rnd+lowerbound)
End Function
Response.Write Getrnd (1,1000)
%>
Method Two:
Copy Code code as follows:
<%
function Rndarray (istart,iend,sum)
Dim Arrayid (), I,j,blnre,temp,iloop,eloop
ReDim Arrayid (Sum-1)
I=0
Iloop=0
Eloop=0
Blnre=false
Randomize
Do While I<sum
Temp=int (rnd* (iend-istart+1) +istart)
If I=0 Then
Arrayid (0) =temp
I=i+1
Iloop=iloop+1
Else
For J=0 to I-1
If Arrayid (j) =temp Then
Blnre=true
Iloop=iloop+1
Exit For ' This sentence is important to prevent unnecessary loops
Else
Iloop=iloop+1
End If
Next
If Blnre=false Then
Arrayid (i) =temp
I=i+1
Else
Blnre=false
End If
End If
Loop
Rndarray=join (Arrayid)
End Function
Response.Write Rndarray (1,5,1) ' Start number, end number, generate number of
%>