请教:固定数字长度,无论数字是多少,都是以6位显视。

ckxp 2003-06-13 04:22:25
比如数字:
3、44、101、9823

显视出来是:
000003、000044、000101、009832
...全文
58 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Cooly 2003-06-13
  • 打赏
  • 举报
回复
写错了
<%
function writenum(num)
writenum=string(6-len(num),"0") & num
end function

response.write writenum(123)
%>
LoneHome 2003-06-13
  • 打赏
  • 举报
回复
function format(str)
if len(str)=6 then format=str
if len(str)<6 then format=string(6-len(str),"0")&str
if len(str)>6 then format=left(str,6)
end function
Cooly 2003-06-13
  • 打赏
  • 举报
回复
太麻烦了
<%
function writenum(num)
writenum=string(6-len(num),"0")
end function

response.write writenum(123)
%>
zhuyngjie 2003-06-13
  • 打赏
  • 举报
回复
<%
function formatnum(num)
numlen=len(num)
if numlen>6 then
'这里是长度大于6的情况(你没说应该怎么处理
else
for i=1 to 6-numlen
num="0"&num
next
formatnum=num
end if
end function
ss=123
response.write formatnum(ss)
%>
caoshangfei 2003-06-13
  • 打赏
  • 举报
回复
<%num="66"
for i=0 to 5-len(num)
num="0"&num
next
response.write num
%>
Cooly 2003-06-13
  • 打赏
  • 举报
回复
dim a,b,c,d
a=3
b=44
c=101
d=9823

response.write string(6-len(a),"0") & a & "<br>"
response.write string(6-len(b),"0") & b & "<br>"
response.write string(6-len(c),"0") & c & "<br>"
response.write string(6-len(d),"0") & d & "<br>"

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧