如何把一长串数字分位显示?
来源:asp之家 时间:2009-11-06 14:01:00
asp函数实现把数字格式化为每3个数字时以逗号间隔的数字
见下:
<%
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>
标签:数字,格式化,显示
0
投稿
猜你喜欢
MySQL系列数据库设计三范式教程示例
2024-01-25 08:15:07
Python使用ntplib库同步校准当地时间的方法
2021-10-07 13:55:32
python处理两种分隔符的数据集方法
2023-06-17 11:24:54
用Python获取亚马逊商品信息
2021-11-22 12:29:04
MySQL存储引擎MyISAM与InnoDB区别总结整理
2024-01-15 13:18:22
php开启mysqli扩展之后如何连接数据库
2023-11-14 17:36:08
numpy之sum()的使用及说明
2023-12-12 00:31:16
Go缓冲channel和非缓冲channel的区别说明
2024-05-22 10:11:01
python os模块介绍
2021-11-06 20:53:16
各种SQL语句速查手册
2007-09-27 19:31:00
Python实现链表反转的方法分析【迭代法与递归法】
2021-07-07 17:56:37
php header功能的使用
2023-11-15 09:25:26
python实现任意位置文件分割的实例
2021-01-17 18:18:22
MySQL学习之日期函数的用法详解
2024-01-21 15:14:55
Python实现暴力破解有密码的zip文件的方法
2023-11-22 22:48:40
标签明晰、有效
2010-01-18 12:22:00
一个带采集远程文章内容,保存图片,生成文件等完整的采集功能
2011-04-02 11:02:00
python matplotlib 画dataframe的时间序列图实例
2023-05-17 00:12:34
WEB标准与XHTML 1.0 Transitional等文档类型介绍
2007-10-20 21:18:00
python增加图像对比度的方法
2022-11-06 09:35:37