asp小写金额转大写的代码

来源:互联网 时间:1970-01-01

asp小写金额转大写

Function UMoney(money) 
Dim lnP,Prc,Tmp,NoB,Dx,Xx,Zhen
Dim China : China = "分角元拾佰仟万拾佰仟亿"
Dim str: str = Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖")  
Zhen = True  
money = FormatNumber(money, 2)  
Prc = CStr(money)  
Prc = Replace(Prc, ",", "")  
lnP = Len(Prc)  
For i = lnP - 1 To 1 Step -1  
If Mid(Prc, i, 1) = "." Then  
Select Case lnP - i  
Case 1  
Prc = Replace(Prc, ".", "") + "0"  
Case 2  
Prc = Replace(Prc, ".", "")  
End Select  
Zhen = False  
Exit For  
End If  
Next  
If Zhen Then Prc = Prc + "00"  
lnP = Len(Prc)  
For i = 1 To lnP  
Tmp = str(Mid(Prc, i, 1)) & Tmp  
Next  
UMoney = ""  
fy = 1  
For i = 1 To lnP  
Xx = Mid(Tmp, i, 1)  
Dx = Mid(China, i, 1)  
If Xx <> "零" Then  
UMoney = Xx & Dx & UMoney  
f = 1  
Else  
If i = 3 Then  
UMoney = Dx & UMoney  
End If  
If i = 7 Then  
UMoney = Dx & UMoney  
End If  
If f Then  
UMoney = "零" & UMoney  
End If  
f = 0  
End If  
Next  
If Zhen Then UMoney = UMoney + "整"  
UMoney = Replace(UMoney, "零万", "万")  
UMoney = Replace(UMoney, "零元", "元")
End Function

相关阅读:
Top