频道直达 - 学院 - 下载 - 交易 - 特效 - 字库 - 手册 -排名-工具- 繁體
网页教学网站开发 设为首页
加入收藏
联系我们
建站搜索: 常用广告代码   用户注册 | 用户登陆
您当前的位置:中国建站之家 -> 网站开发设计技术教程 -> asp教程 -> 把长的数字用逗号隔开显示

把长的数字用逗号隔开显示

作者:未知  来源:转载  发布时间:2005-9-17 21:15:33  发布人:acx

减小字体 增大字体

Code Title: Proper Number
Description: If you have a long number to display, then why not make it split the number up correctly with
a comma?

For example, the number 12345678 looks odd, right? Ok, let's apply the Comma() function to that number and
display it like this automatically: 12,345,678 -much cleaner!

By the way, this script supports numbers as long as 15 characters (numbers), so if you have a longer
number than that, we may need to work together to advance this script a bit, but this snippet will work
just fine for your average numbers. Thanx to Dave Cantrell for this advice!
Copy and paste this snippet as-is into your editor:

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>


将本文收藏到QQ书签与更多好友分享
[打 印]
[] [返回上一页] [收 藏]
∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
精彩推荐
热门文章
· 注册码大全二
· 注册码大全四
· 注册码大全一
· 要10G免费网络硬盘的请进..
· 通过google 赶快来赚美金..
· 注册码大全十
· 头像-qq头像(qq新头像)4..
· 让你轻松架设FTP服务器1..
· 注册码大全三
· 梦幻背景图片7
· 卡通动物图片6
· 网页制作素材-按钮素材2..
· 让你轻松架设FTP服务器5..
· 风景图片8
· 注册码大全九
· 让你轻松架设FTP服务器2..
关注此文读者还看过
· 基于PHP的聊天室(二)
· 手绘教程 《月份牌年画》..
· ASP技术在论坛中的运用(..
· 用PHP将数据导入到Foxma..
· 如何让Flash4可以开启Fl..
· 个性化我的Flash(2)
· 树的绘画过程
· 关于交叉报表的动态实现..
· 网页标题Title如何写才能..
· 如何在网页中存取剪贴板..
· ASP.NET高级教程(3):对象..
· 什么是Wiki?
· 最容易被黑客盯上的注册..
· 把BLOG上传到远程空间-D..
· photoshop高难度抠图的方..
· Photoshop通道混合器原理..
相关文章
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 人才招聘
网站合作、内容监督、商务咨询:QQ: 9576619
Copyright ? 2005--2008 中国建站之家版权所有
粤ICP备05092265号