当前位置:主页 > 查看内容

如何把一长串数字分位显示?

发布时间:2021-04-19 00:00| 位朋友查看

简介:% 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 =……

<%
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"
%>
原来的数字: <%=aLongNumber%><br>
用逗号格式化后: <%=Comma(aLongNumber)%>
</body></html>


本文转载自网络,原文链接:https://m.jb51.net/article/4694.htm
本站部分内容转载于网络,版权归原作者所有,转载之目的在于传播更多优秀技术内容,如有侵权请联系QQ/微信:153890879删除,谢谢!

推荐图文


随机推荐