ASP把長的數(shù)字用逗號隔開顯示的代碼
更新時間:2008年06月18日 21:25:05 作者:
對于一些比較長的數(shù)字,我們可以用asp實現(xiàn)隔開顯示,尤其是一些金錢相關(guān)的東西
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>
復(fù)制代碼 代碼如下:
<%
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>
相關(guān)文章
在ASP中連接MySQL數(shù)據(jù)庫,最好的通過ODBC方法
在ASP中連接MySQL數(shù)據(jù)庫,最好的通過ODBC方法...2006-11-11微信公眾號可通過現(xiàn)金紅包接口發(fā)放微信支付現(xiàn)金紅包(附開發(fā)教程)
這篇文章主要介紹了微信公眾號可通過現(xiàn)金紅包接口發(fā)放微信支付現(xiàn)金紅包的相關(guān)資料,需要的朋友可以參考下2016-09-09不用模板只用ASP+FSO生成靜態(tài)HTML頁的一個方法
不用模板只用ASP+FSO生成靜態(tài)HTML頁的一個方法...2006-09-09