asp 生成任意英文+数字位数长度的随机码函数

时间:2022-09-18 12:44:09
  1. <%  
  2. '******************************  
  3. '函数:Generator(Length)  
  4. '参数:Length,任意长度的数值,随机码位数  
  5. '作者:阿里西西  
  6. '日期:2007/7/15  
  7. '描述:生成任意英文+数字位数长度的随机码函数  
  8. '示例:Generator(80)  
  9. '******************************  
  10. Function Generator(Length)  
  11.  Dim i, tempS  
  12.  tempS = "abcdefghijklmnopqrstuvwxyz1234567890"   
  13.  Generator = ""  
  14.  If isNumeric(Length) = False Then   
  15.   Exit Function   
  16.  End If   
  17.  For i = 1 to Length   
  18.   Randomize   
  19.   Generator = Generator & Mid(tempS,Int((Len(tempS) * Rnd) + 1),1)  
  20.  Next   
  21. End Function   
  22. %>