网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的考试资料:

 

标题 使用vbscript生成36进制自动增长序号的实现代码
内容
    asp生成0~9,a~z的36进制字符串,运行下面示例需要使用IE核心的浏览器,其他非IE核心浏览器不支持vbscript。
    实现代码:
    ?1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 <script language="vbscript"> function getinitstring(l)'初始化指定长度的0字符串 l=l-1 for i=0 to l getinitstring="0"&getinitstring next end function function getnextchar(chrcode)'获取下一个字符 if chrcode=57 then'数字和字母标ascii不连贯,需要特殊处理一下 getnextchar="a" else getnextchar=chr(chrcode+1) end if end function function 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 then getnextno="已经达到最大长度,无法继续进位,需要修改长度":exit function end if end if if 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) next end function s=""initlen=6 s=getnextno(s,initlen) msgbox s'000000 s=getnextno(s,initlen) msgbox s'000001 s="aaazzz"s=getnextno(s,initlen) msgbox s'aab000 s="zzzzzz"s=getnextno(s,initlen) msgbox s'已经达到最大长度,无法继续进位,需要修改长度 </script>
随便看

 

在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/21 5:32:17