自动生成排序的几位数的代码

来源:互联网 发布:淘宝怎么找自己的账号 编辑:程序博客网 时间:2024/05/22 16:16

function RanNum(weishu)
 if weishu="" or not isnumeric(weishu) then
  weishu=8
 else
  weishu=cint(weishu)
 end if

 set rs=server.CreateObject("adodb.recordset")
 sql="select max(wb_bh) from wangba "

 rs.open sql,conn,1,1
 if rs.eof then
  RanNum="CX"
  for i=1 to weishu-1
   RanNum= RanNum&"0"
  next
  RanNum= RanNum&"1"
 else
  if isnull(rs(0)) then
   RanNum="CX"
   for i=1 to weishu-1
    RanNum= RanNum&"0"
   next
   RanNum= RanNum&"1"
  else
   str=rs(0)
  
   str=right(str,weishu-4)
   str=cint(str)+1
   RanNum="CX"
  for i=3 to weishu-len(str)
      RanNum=RanNum&"0"
  next
  RanNum=RanNum&cstr(str)
        end if
 end if
end function

 

 

调用<%=RanNum(8)%>

 

原创粉丝点击