正在加载中...
信息详页
返回案例1-随机码
<% 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 'character 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 %> <% '6是长度 %> <%=makePassword(6)%>案例2-随机码
<% 'ASP生成随机字符串(数字+大小写字母)练习 '阿会楠练习,为我所用,非我所想 Function randKey(obj) Dim char_array(80) Dim temp 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 For i = 1 To obj 'rnd函数返回的随机数在0~1之间,可等于0,但不等于1 '公式:int((上限-下限+1)*Rnd+下限)可取得从下限到上限之间的数,可等于下限但不可等于上限 temp = temp&char_array(int(62 - 0 + 1)*Rnd + 0) Next randKey = temp End Function Response.Write(randKey(6)) %>