ASP生成随机字符串(数字+大小写字母)的代码
程序员文章站
2022-07-01 23:44:19
<% 'asp生成随机字符串(数字+大小写字母)练习 '阿会楠练习,为我所用,非我所想 function randkey(obj) ...
<%
'asp生成随机字符串(数字+大小写字母)练习
'阿会楠练习,为我所用,非我所想
function randkey(obj)
dim char_array(80)
dim temp
for i = 0 to 9
char_array(i) = cstr(i)
next
for i = 10 to 35
char_array(i) = chr(i + 55)
next
for i = 36 to 61
char_array(i) = chr(i + 61)
next
randomize
for i = 1 to obj
'rnd函数返回的随机数在0~1之间,可等于0,但不等于1
'公式:int((上限-下限+1)*rnd+下限)可取得从下限到上限之间的数,可等于下限但不可等于上限
temp = temp&char_array(int(62 - 0 + 1)*rnd + 0)
next
randkey = temp
end function
response.write(randkey(6))
%>
'asp生成随机字符串(数字+大小写字母)练习
'阿会楠练习,为我所用,非我所想
function randkey(obj)
dim char_array(80)
dim temp
for i = 0 to 9
char_array(i) = cstr(i)
next
for i = 10 to 35
char_array(i) = chr(i + 55)
next
for i = 36 to 61
char_array(i) = chr(i + 61)
next
randomize
for i = 1 to obj
'rnd函数返回的随机数在0~1之间,可等于0,但不等于1
'公式:int((上限-下限+1)*rnd+下限)可取得从下限到上限之间的数,可等于下限但不可等于上限
temp = temp&char_array(int(62 - 0 + 1)*rnd + 0)
next
randkey = temp
end function
response.write(randkey(6))
%>