ASP把长的数字用逗号隔开显示的代码
程序员文章站
2022-04-14 19:16:12
000000000000000000000000000000000000000000000000000000000000000 复制代码 代码如下:<% ...
000000000000000000000000000000000000000000000000000000000000000
<%
function comma(str)
if not(isnumeric(str)) or str = 0 then
result = 0
elseif len(fix(str)) < 4 then
result = str
else
pos = instr(1,str,".")
if pos > 0 then
dec = mid(str,pos)
end if
res = strreverse(fix(str))
loopcount = 1
while loopcount <= len(res)
tempresult = tempresult + mid(res,loopcount,3)
loopcount = loopcount + 3
if loopcount <= len(res) then
tempresult = tempresult + ","
end if
wend
result = strreverse(tempresult) + dec
end if
comma = result
end function
%>
<html>
<body>
<%
alongnumber = "12345678"
%>
an un-formatted number: <%=alongnumber%><br>
the comma formatted number: <%=comma(alongnumber)%>
</body>
</html>
复制代码 代码如下:
<%
function comma(str)
if not(isnumeric(str)) or str = 0 then
result = 0
elseif len(fix(str)) < 4 then
result = str
else
pos = instr(1,str,".")
if pos > 0 then
dec = mid(str,pos)
end if
res = strreverse(fix(str))
loopcount = 1
while loopcount <= len(res)
tempresult = tempresult + mid(res,loopcount,3)
loopcount = loopcount + 3
if loopcount <= len(res) then
tempresult = tempresult + ","
end if
wend
result = strreverse(tempresult) + dec
end if
comma = result
end function
%>
<html>
<body>
<%
alongnumber = "12345678"
%>
an un-formatted number: <%=alongnumber%><br>
the comma formatted number: <%=comma(alongnumber)%>
</body>
</html>
上一篇: 干掉小偷的不是警察
下一篇: asp 合并记录集并删除的sql语句