分享你我的心得.
共乘一片美好网络.

asp货币金额转换

<%
Function uMoney(money)
If Not IsNumeric(money) or money>9999999999999.99 Then
uMoney=”超出范围”
Exit Function
else
uMoney=””
end if
Dim numList : numList = array(“零”,”壹”,”贰”,”叁”,”肆”,”伍”,”陆”,”柒”,”捌”,”玖”)
Dim rmbList : rmbList = array(“元”,”拾”,”佰”,”仟”,”万”,”拾”,”佰”,”仟”,”亿”,”拾”,”佰”,”仟”,”万”)
Dim rList : rList = array(“零分”,”零角”,”零元”,”零拾”,”零佰”,”零仟”,”零万”,”零亿”)
Dim tList : tList = array(“整”,”零”,”元”,”零”,”零”,”零”,”万”,”亿”)
money = cStr(FormatNumber(money,2,0,0,0))
Dim moneyArr : moneyArr = split(money,”.”)
Dim mLen : mLen = len(moneyArr(0))
Dim i,n
for i=1 to mLen
n = int(Mid(moneyArr(0),i,1))
uMoney = uMoney & numList(n) & rmbList(mLen-i)
next
uMoney = uMoney & numList(left(moneyArr(1),1)) & “角” & numList(right(moneyArr(1),1)) & “分”
for i=0 to ubound(rList)
uMoney = replace(uMoney,rList(i),tList(i))
next
while instr(uMoney,”零零”)<>0
uMoney = replace(uMoney,”零零”,”零”)
wend
uMoney = Replace(uMoney, “零亿”, “亿”)
uMoney = Replace(uMoney, “零万”, “万”)
uMoney = Replace(uMoney, “亿万”, “亿”)
uMoney = Replace(uMoney, “零元”, “元”)
uMoney = Replace(uMoney, “零整”, “整”)
End Function
%>
<%
response.write uMoney(201410.17)
%>

赞(0)
未经允许不得转载:小叶白龙博客 » asp货币金额转换
分享到: 更多 (0)

评论 抢沙发

评论前必须登录!