asp生成0~9,a~z的36进制字符串,运行下面示例需要使用IE核心的浏览器,其他非IE核心浏览器不支持vbscript。
实现代码:
<script language="vbscript">function getinitstring(l)"初始化指定长度的0字符串 l=l-1 for i=0 to lgetinitstring="0"&getinitstring nextend functionfunction getnextchar(chrcode)"获取下一个字符 if chrcode=57 then"数字和字母标ascii不连贯,需要特殊处理一下getnextchar="a" elsegetnextchar=chr(chrcode+1) end ifend functionfunction getnextno(s,l)"获取下自增1的字符串 if trim(s)="" then"初始化字符串getnextno=getinitstring(l):exit function end if l=len(s)-1 dim a():redim a(l) for i=0 to l"拆分成数组a(i)=mid(s,i+1,1) next carry=false"进位标志 for i=l to 0 step -1"从最低位开始遍历chrcode=asc(a(i))if carry then if chrcode<>122 then"不是z,自增后退出for循环,否则继续进位a(i)=getnextchar(chrcode):exit for"退出循环 elseif i=0 thengetnextno="已经达到最大长度,无法继续进位,需要修改长度":exit function end ifend ifif a(i)="z" then carry=true:a(i)="0"else a(i)=getnextchar(chrcode):exit for"退出循环end if next for i=0 to l"组合返回字符串getnextno=getnextno&a(i) nextend functions=""initlen=6s=getnextno(s,initlen)msgbox s"000000s=getnextno(s,initlen)msgbox s"000001s="aaazzz"s=getnextno(s,initlen)msgbox s"aab000s="zzzzzz"s=getnextno(s,initlen)msgbox s"已经达到最大长度,无法继续进位,需要修改长度</script>