asp 一次生成多条(英文+数字)随机数代码
<%Functiongen_key(digits)dimchar_array(25)char_array(0)="A"char_array(1)="B"char_arra...
<%
Function gen_key(digits)
dim char_array(25)
char_array(0) = "A"
char_array(1) = "B"
char_array(2) = "C"
char_array(3) = "D"
char_array(4) = "E"
char_array(5) = "F"
char_array(6) = "G"
char_array(7) = "H"
char_array(8) = "I"
char_array(9) = "J"
char_array(10) = "K"
char_array(11) = "L"
char_array(12) = "M"
char_array(13) = "N"
char_array(14) = "O"
char_array(15) = "P"
char_array(16) = "Q"
char_array(17) = "R"
char_array(18) = "S"
char_array(19) = "T"
char_array(20) = "U"
char_array(21) = "V"
char_array(22) = "W"
char_array(23) = "X"
char_array(24) = "Y"
char_array(25) = "Z"
randomize
do while len(output) < digits
num = char_array(Int(25 * Rnd + 0))
output = output + num
loop
gen_key = output
End Function
%>
<%
Function gen_key1(digits)
dim char_array(9)
char_array(0) = "0"
char_array(1) = "1"
char_array(2) = "2"
char_array(3) = "3"
char_array(4) = "4"
char_array(5) = "5"
char_array(6) = "6"
char_array(7) = "7"
char_array(8) = "8"
char_array(9) = "9"
randomize
do while len(output) < digits
num = char_array(Int(9 * Rnd + 0))
output = output + num
loop
gen_key1 = output
End Function
%>
<%
dim n
n=10
dim A,B,C()
redim C(n)
for i=1 to n
A=gen_key(7)
B=gen_key1(8)
C(i) = A & B
next
dim mark
for i=1 to n
mark=true
for j=2 to i
if C(i) = C(j) then mark=false
next
if mark then response.Write((C(i) & "</br>"))
next
%>
上面这段代码显示的是只是一条随机数(如:QJYJYPO76160857)我要的效果是显示多条 其中 n=10 我指定显示10条 可是程序好像没走 for 循环就输出了,请高手帮忙看看是什么问题.... 展开
Function gen_key(digits)
dim char_array(25)
char_array(0) = "A"
char_array(1) = "B"
char_array(2) = "C"
char_array(3) = "D"
char_array(4) = "E"
char_array(5) = "F"
char_array(6) = "G"
char_array(7) = "H"
char_array(8) = "I"
char_array(9) = "J"
char_array(10) = "K"
char_array(11) = "L"
char_array(12) = "M"
char_array(13) = "N"
char_array(14) = "O"
char_array(15) = "P"
char_array(16) = "Q"
char_array(17) = "R"
char_array(18) = "S"
char_array(19) = "T"
char_array(20) = "U"
char_array(21) = "V"
char_array(22) = "W"
char_array(23) = "X"
char_array(24) = "Y"
char_array(25) = "Z"
randomize
do while len(output) < digits
num = char_array(Int(25 * Rnd + 0))
output = output + num
loop
gen_key = output
End Function
%>
<%
Function gen_key1(digits)
dim char_array(9)
char_array(0) = "0"
char_array(1) = "1"
char_array(2) = "2"
char_array(3) = "3"
char_array(4) = "4"
char_array(5) = "5"
char_array(6) = "6"
char_array(7) = "7"
char_array(8) = "8"
char_array(9) = "9"
randomize
do while len(output) < digits
num = char_array(Int(9 * Rnd + 0))
output = output + num
loop
gen_key1 = output
End Function
%>
<%
dim n
n=10
dim A,B,C()
redim C(n)
for i=1 to n
A=gen_key(7)
B=gen_key1(8)
C(i) = A & B
next
dim mark
for i=1 to n
mark=true
for j=2 to i
if C(i) = C(j) then mark=false
next
if mark then response.Write((C(i) & "</br>"))
next
%>
上面这段代码显示的是只是一条随机数(如:QJYJYPO76160857)我要的效果是显示多条 其中 n=10 我指定显示10条 可是程序好像没走 for 循环就输出了,请高手帮忙看看是什么问题.... 展开
1个回答
展开全部
dim A,B,
放在 for i=1 to n
下面
如果觉得还团启有问题,旅或扰就将拆旦A,B 在next重置一次
放在 for i=1 to n
下面
如果觉得还团启有问题,旅或扰就将拆旦A,B 在next重置一次
更多追问追答
追问
按照你说的,第1种方法我试过了,还是不显示循环。第2种你说的把A,B在next重置方法,我不是太明白,麻烦你说一下 A,B 应该在哪个位置加 谢谢了。
追答
dim A,B,C()
redim C(n)
for i=1 to n
A=gen_key(7)
B=gen_key1(8)
C(i) = A & B
next
dim mark
for i=1 to n
mark=true
for j=2 to i
if C(i) = C(j) then mark=false
next
if mark then response.Write((C(i) & ""))
next
A = ""
B = ""
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询