<%
'**************************************************
'函数名:MakeRandomChar
'作 用:生成指定位数的随机数字符串 如 "sJKD_!@KK"
'参 数: Length ----生成位数
'返回值:成功返回随机字符串
'**************************************************
Function MakeRandomChar(Length)
Dim I, tempS, v
Dim c(65)
tempS = ""
c(1) = "a": c(2) = "b": c(3) = "c": c(4) = "d": c(5) = "e": c(6) = "f": c(7) = "g"
c(8) = "h": c(9) = "i": c(10) = "j": c(11) = "k": c(12) = "l": c(13) = "m": c(14) = "n"
c(15) = "o": c(16) = "p": c(17) = "q": c(18) = "r": c(19) = "s": c(20) = "t": c(21) = "u"
c(22) = "v": c(23) = "w": c(24) = "x": c(25) = "y": c(26) = "z": c(27) = "1": c(28) = "2"
c(29) = "3": c(30) = "4": c(31) = "5": c(32) = "6": c(33) = "7": c(34) = "8": c(35) = "9"
c(36) = "-": c(37) = "_": c(38) = "@": c(39) = "!": c(40) = "A": c(41) = "B": c(42) = "C"
c(43) = "D": c(44) = "E": c(45) = "F": c(46) = "G": c(47) = "H": c(48) = "I": c(49) = "J": c(50) = "K"
c(51) = "L": c(52) = "M": c(53) = "N": c(54) = "O": c(55) = "P": c(56) = "Q": c(57) = "R": c(58) = "S"
c(59) = "J": c(60) = "U": c(61) = "V": c(62) = "W": c(63) = "X": c(64) = "Y": c(65) = "Z"
If IsNumeric(Length) = False Then
MakeRandomChar = "":Exit Function
End If
For I = 1 To Length
Randomize
v = Int((65 * Rnd) + 1):tempS = tempS & c(v)
Next
MakeRandomChar = tempS
End Function
%><br />
调用方式:<%response.write MakeRandomChar(12)%>
显示效果 jePpdSjwaaK7