人民币小写转大写

2008-02-23 06:53:47来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

Public Function ZDX(X As Currency) As String
Dim lnP As Integer
Dim Prc As String
Dim Tmp As String
Dim NoB As Currency
Dim Dx As String
Dim Xx As String
Dim Zhen As Boolean
Dim Str(10) As String
Dim China As String
China = "分角元拾佰仟万拾佰仟亿"
Str(0) = "零"
Str(1) = "壹"
Str(2) = "贰"
Str(3) = "叁"
Str(4) = "肆"
Str(5) = "伍"
Str(6) = "陆"
Str(7) = "柒"
Str(8) = "捌"
Str(9) = "玖"

Zhen = True
X = FormatNumber(X, 2)
Prc = CStr(X)
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 i
If Zhen Then Prc = Prc "00"
lnP = Len(Prc)
For i = 1 To lnP
Tmp = Str(Mid(Prc, i, 1)) & Tmp
Next i

ZDX = ""
fy = 1
For i = 1 To lnP
Xx = Mid(Tmp, i, 1)
Dx = Mid(China, i, 1)

If Xx <> "零" Then
ZDX = Xx & Dx & ZDX
f = 1
Else
If i = 3 Then
ZDX = Dx & ZDX
End If

If i = 7 Then
ZDX = Dx & ZDX
End If
If f Then
ZDX = "零" & ZDX
End If
f = 0
End If
Next i
If Zhen Then ZDX = ZDX "正"
ZDX = Replace(ZDX, "零万", "万")
ZDX = Replace(ZDX, "零元", "元")

End Function

上一篇: 用VB实现鼠标的隐藏
下一篇: 将ENTER变成TAB键

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:使用VBA-Excel97绘图

下一篇:将ENTER变成TAB键