第一种函数方法:
function rndNumLetters(num) randomize dim num0,num1,num2,num3,pass if num = "" or not isnumeric(num) or num < 1 then num0 = 6 else num0 = num end if do while len(pass)<num0 '随机密码位数 num1=cstr(chr((57-48)*rnd+48))' 0~9 num2=cstr(chr((90-65)*rnd+65)) 'a~z num3=cstr(chr((122-97)*rnd+97)) 'a~z pass=pass&num1&num2&num3 loop rndNumLetters = pass end function
第二种函数方法:
Function rndNumLetters2(StrLng,StrNum) dim TmpStr TmpStr = "0123456789abcdefghijklmnopqrstopwxyz" for iii=1 to Strnum for jjj = 1 to StrLng Randomize strLen = Len(TmpStr) t = Round((RND * (strLen-1))+1) s = s & mid(TmpStr,t,1) Next s=s& " <br> " Next RoundStr = s End Function
第三种函数方法:
Function rndNumLetters3(StrLng) dim TmpStr TmpStr = "0123456789abcdefghijklmnopqrstopwxyz" for j = 1 to StrLng Randomize strLen = Len(TmpStr) t = Round((RND * (strLen-1))+1) s = s & mid(TmpStr,t,1) Next RoundStr2 = s End Function