您的位置:首页 > 编程语言 > ASP

用ASP编程语言实现生成随机字符串

2014-07-31 22:11 246 查看
<%

Function GetRandom(RandomLength)

'定义并初始化数组

dim char_array(80)

'初始化数字

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 '初始化随机数生成器

do while len(output) < RandomLength

num = char_array(Int((62 - 0 + 1) * Rnd + 0))

output = output + num

loop

GetRandom = output

End Function

response.write "本实例生成的20位随机字符串为:"

response.write "<br><br>"

response.write GetRandom(20)

response.end()
%>

代码摘自:http://www.kxcom.net/jishu/asp_cjgndsx.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  asp 实例