加入收藏 | 设为首页 | 会员中心 | 我要投稿 聊城站长网 (https://www.0635zz.com/)- 智能语音交互、行业智能、AI应用、云计算、5G!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

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

发布时间:2023-05-23 14:12:27 所属栏目:Asp教程 来源:
导读:对于一些比较长的数字,我们可以用asp实现隔开显示,尤其是一些金钱相关的东西

000000000000000000000000000000000000000000000000000000000000000

复制代码代码如下:

<%

Function Comma(str)

I
对于一些比较长的数字,我们可以用asp实现隔开显示,尤其是一些金钱相关的东西
 
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>
 
 

(编辑:聊城站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章