asp中 怎么样 格式化数字1为001?

现有1到500个数字,现在要格式化为三位数比如1显示为0012显示为00239显示为039

第1个回答  2012-08-11
<%
for num=1 to 500
if len(num)<4 then num=right("000" & num,3)
response.write num
response.write "<br>"

next
%>
第2个回答  2012-08-11
<%
a=39
response.write String(3-len(a),"0") & a
%>

这里使用到了VBScript的String 函数。
具体可以看http://www.jb51.net/shouce/vbs/vsfctString.htm
相似回答