网络编程
位置:首页>> 网络编程>> Asp编程>> 8个asp生成随机字符的函数(3)

8个asp生成随机字符的函数(3)

 来源:asp之家 发布时间:2007-08-04 10:17:00 

标签:随机函数,随机,随机字符,函数

5.
功能说明:返回指定长度的随机字符,大小写英文字母加数字组成


function makePassword(byVal maxLen)
Dim strNewPass
Dim whatsNext, upper, lower, intCounter
Randomize
For intCounter = 1 To maxLen
whatsNext = Int((1 - 0 + 1) * Rnd + 0)
If whatsNext = 0 Then
upper = 90
lower = 65
Else
upper = 57
lower = 48
End If
strNewPass = strNewPass & Chr(Int((upper - lower + 1) * Rnd + lower))
Next
makePassword = strNewPass
end function

使用方法:

dim  radpass
response.write makePassword(6) ’6位字符


6.
功能说明:生成任意位随机数的函数
'strLong是随机数字的位数,返回指定长度的数字串,不含字母

Function rndNum (strLong) 
Dim temNum 
Randomize 
Do While Len(RndNum) < strLong 
temNum=CStr(Chr((57-48)*rnd+48)) 
RndNum=RndNum&temNum 
loop 
End Function 


使用方法:

response.write rndNum(6)

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com