asp生成0~9,a~z的36进制字符串,运行下面示例需要使用IE核心的浏览器,其他非IE核心浏览器不支持vbscript。

实现代码:

<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>

标签:
vbscript,36进制,自动增长序号

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com

RTX 5090要首发 性能要翻倍!三星展示GDDR7显存

三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。

首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。

据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。