ASP把长的数字用逗号隔开显示的代码
发布时间:2016-12-29 来源:查字典编辑
摘要:000000000000000000000000000000000000000000000000000000000000000复制代码代码如...
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>