内容显示页
 
类别:ASP+VBS | 浏览(235) | 2006-10-31 12:21:00

Function NumRand(n) '生成n位随机数字
  For i=1 to n
    Randomize
    temp = cint(9*Rnd)
    temp = temp + 48
    NumRand = NumRand & chr(temp)
  Next
End Function
msgbox NumRand(5),,"生成n位随机数字"


Function LCharRand(n) '生成n位随机小写字母
  For i=1 to n
    Randomize
    temp = cint(25*Rnd)
    temp = temp +97
    LCharRand = LCharRand & chr(temp)
  Next
End Function
msgbox LCharRand(5),,"生成n位随机小写字母"


Function UCharRand(n) '生成n位随机大写字母
  For i=1 to n
    Randomize
    temp = cint(25*Rnd)
    temp = temp +65
    UCharRand = UCharRand & chr(temp)
  Next
End Function
msgbox UCharRand(5),,"生成n位随机大写字母"


Function allRand(n) '生成n位随机数字字母子组合
  For i=1 to n
    Randomize
    temp = cint(25*Rnd)
    If temp mod 2 = 0 then
      temp = temp + 97
    ElseIf temp < 9 then
      temp = temp + 48
    Else
      temp = temp + 65
    End If
    allRand = allRand & chr(temp)
  Next
End Function
msgbox allRand(5),,"生成n位随机数字字母子组合"

 

把以上内容存为rand.vbs双击运行,可以看到效果。


引用本页地址:http://www.yongfa365.com/item/24872997f7a1f06b.html
 
 
相关链接
 
网友评论:
姓名: 记住我
网址:
邮箱:
内容:
验证码:  验证码图片 看不清? 换张图试试
 
     
 
 
文章分类
 
 
专题(3)
 
.Net + C#(41)
 
ASP+VBS(153)
 
 
 
Linux(10)
 
 
 
web 2.0(24)
 
 
 
 
 
心程(59)
 
生活(80)
 
 
     

Power by :柳永法(yongfa365)'Blog | Model by :hibaidu | CSS by:众网友 | 京ICP备07011491号  QQ:64049027  E-mail:64049027qq.com

本空间赞助商:北京中科兴联信息技术有限公司