ASP把长的数字用逗号隔开显示的代码

2018-09-06 13:09

阅读:362

  000000000000000000000000000000000000000000000000000000000000000
复制代码 代码如下:
<%
FunctionComma(str)
IfNot(IsNumeric(str))orstr=0Then
Result=0
ElseIfLen(Fix(str))<4Then
Result=str
Else
Pos=Instr(1,str,.)
IfPos>0Then
Dec=Mid(str,Pos)
Endif
Res=StrReverse(Fix(str))
LoopCount=1
WhileLoopCount<=Len(Res)
TempResult=TempResult+Mid(Res,LoopCount,3)
LoopCount=LoopCount+3
IfLoopCount<=Len(Res)Then
TempResult=TempResult+,
EndIf
Wend
Result=StrReverse(TempResult)+Dec

EndIf
Comma=Result
EndFunction
%>
<html>
<body>
<%
aLongNumber=12345678
%>
Anun-formattednumber:<%=aLongNumber%><br>
TheCommaformattednumber:<%=Comma(aLongNumber)%>
</body>
</html>


评论


亲,登录后才可以留言!