asp下返回以千分位显示数字格式化的数值
发布时间:2016-12-29 来源:查字典编辑
摘要:
<%
'******************************
'函数:comma(str)
'参数:str,待处理的数字
'作者:阿里西西
'日期:2007/7/12
'描述:返回以千分位显示数字格式化的数值
'示例:<%=comma("120300")%>
'******************************
functioncomma(str)
ifnot(isnumeric(str))orstr=0then
result=0
elseiflen(fix(str))<4then
result=str
else
pos=instr(1,str,".")
ifpos>0then
dec=mid(str,pos)
endif
res=strreverse(fix(str))
loopcount=1
whileloopcount<=len(res)
tempresult=tempresult+mid(res,loopcount,3)
loopcount=loopcount+3
ifloopcount<=len(res)then
tempresult=tempresult+","
endif
wend
result=strreverse(tempresult)+dec
endif
comma=result
endfunction
%>