网络编程 
首页 > 网络编程 > 浏览文章

asp下返回以千分位显示数字格式化的数值

(编辑:jimmy 日期: 2024/5/20 浏览:3 次 )
<%
'******************************
'函数:comma(str)
'参数:str,待处理的数字
'作者:阿里西西
'日期:2007/7/12
'描述:返回以千分位显示数字格式化的数值
'示例:<%=comma("120300")%>
'******************************
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 
%>
上一篇:asp重定向页面的方法总结
下一篇:asp 下产生任意位数随机密码的代码
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网