VB 程序设计

10个成员

人民币小写转大写

发表于 2016-12-19 3413 次查看
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

 

发表回复
你还没有登录,请先登录注册