'我写的小东西,没有优化,没有问题,就是烂了点 '此处将小写的金额转变为大写的金额 Public Function digitToUper(lAccount As String) As String Dim sStrPara As String Dim tempStr As String Dim DaXie As String Dim ShuZi As Integer Dim LastZero As Boolean Dim AllZero As Boolean Dim ifWan As Boolean Dim ifYi As Boolean Dim LastShuzi As Integer Dim Length As Integer, i As Integer Dim DotPos As Integer Dim ZhengShuPart As String Dim XiaoShuPart As String Dim ifFuzhi As Boolean Dim NumString(21) As String NumString(0) = "零" NumString(1) = "壹" NumString(2) = "贰" NumString(3) = "叁" NumString(4) = "肆" NumString(5) = "伍" NumString(6) = "陆" NumString(7) = "柒" NumString(8) = "捌" NumString(9) = "玖" NumString(10) = "拾" NumString(11) = "佰" NumString(12) = "仟" NumString(13) = "万" NumString(14) = "拾万" NumString(15) = "佰万" NumString(16) = "仟万" NumString(17) = "亿" NumString(18) = "拾亿" NumString(19) = "佰亿" NumString(20) = "仟亿"
digitToUper = "" If IsNull(lAccount) Then Exit Function If Trim(lAccount) = "" Then Exit Function If Not IsNumeric(lAccount) Then Exit Function sStrPara = lAccount If CCur(sStrPara) < 0 Then ifFuzhi = True sStrPara = Mid(sStrPara, 2) End If sStrPara = CStr(Format(CCur(sStrPara), "##0.00"))
DotPos = InStr(1, sStrPara, ".") If DotPos = 0 Then XiaoShuPart = "" Else XiaoShuPart = Mid(sStrPara, DotPos + 1) If Len(XiaoShuPart) > 2 Then XiaoShuPart = Left(XiaoShuPart, 2) End If End If If XiaoShuPart <> "" Then If CInt(XiaoShuPart) = 0 Then XiaoShuPart = "整" Else tempStr = Mid(XiaoShuPart, 1, 1) ShuZi = CInt(tempStr) DaXie = NumString(ShuZi) If ShuZi <> 0 Then DaXie = DaXie & "角" If Len(XiaoShuPart) > 1 Then tempStr = Mid(XiaoShuPart, 2, 1) ShuZi = CInt(tempStr) If ShuZi <> 0 Then DaXie = DaXie & NumString(ShuZi) & "分" End If End If XiaoShuPart = DaXie End If Else XiaoShuPart = "整" End If If DotPos <> 0 Then ZhengShuPart = Left(sStrPara, DotPos - 1) Else ZhengShuPart = sStrPara End If If CDbl(ZhengShuPart) = 0 Then If XiaoShuPart <> "整" Then digitToUper = XiaoShuPart Else digitToUper = NumString(0) End If Exit Function Else LastZero = False AllZero = True DaXie = "元" ifWan = False Length = Len(ZhengShuPart) + 1 For i = Len(ZhengShuPart) To 1 Step -1 tempStr = Mid(ZhengShuPart, i, 1) ShuZi = CInt(tempStr) If ShuZi = 0 Then If Not AllZero And Not LastZero Then DaXie = NumString(0) & DaXie End If If Length - i = 1 And XiaoShuPart <> "整" Then If Mid(XiaoShuPart, 1, 1) <> NumString(0) Then DaXie = DaXie & NumString(0) End If LastZero = True Else AllZero = False LastZero = False If Length - i = 2 Then DaXie = NumString(10) & DaXie If Length - i = 3 Then DaXie = NumString(11) & DaXie If Length - i = 4 Then DaXie = NumString(12) & DaXie If Length - i >= 5 And Not ifWan Then DaXie = NumString(13) & DaXie ifWan = True End If If ifWan Then If Length - i - 5 = 1 Then DaXie = NumString(10) & DaXie If Length - i - 5 = 2 Then DaXie = NumString(11) & DaXie If Length - i - 5 = 3 Then DaXie = NumString(12) & DaXie If Length - i - 5 >= 4 And Not ifYi Then DaXie = NumString(17) & DaXie ifYi = True End If If ifYi Then If Length - i - 5 - 4 = 1 Then DaXie = NumString(10) & DaXie If Length - i - 5 - 4 = 2 Then DaXie = NumString(11) & DaXie If Length - i - 5 - 4 = 3 Then DaXie = NumString(12) & DaXie If Length - i - 5 - 4 = 4 Then DaXie = NumString(13) & DaXie If Length - i - 5 - 4 = 5 Then DaXie = NumString(14) & DaXie If Length - i - 5 - 4 = 6 Then DaXie = NumString(15) & DaXie If Length - i - 5 - 4 = 7 Then DaXie = NumString(16) & DaXie End If End If DaXie = NumString(ShuZi) & DaXie End If Next If Len(DaXie) > 2 Then tempStr = Mid(DaXie, 1, 2) If tempStr = NumString(1) & NumString(10) Then DaXie = Mid(DaXie, 2) End If End If If ifFuzhi Then DaXie = "负" & DaXie End If ZhengShuPart = DaXie End If digitToUper = ZhengShuPart & XiaoShuPart End Function
'此处将小写的金额转变为大写的金额
Public Function digitToUper(lAccount As String) As String
Dim sStrPara As String
Dim tempStr As String
Dim DaXie As String
Dim ShuZi As Integer
Dim LastZero As Boolean
Dim AllZero As Boolean
Dim ifWan As Boolean
Dim ifYi As Boolean
Dim LastShuzi As Integer
Dim Length As Integer, i As Integer
Dim DotPos As Integer
Dim ZhengShuPart As String
Dim XiaoShuPart As String
Dim ifFuzhi As Boolean
Dim NumString(21) As String
NumString(0) = "零"
NumString(1) = "壹"
NumString(2) = "贰"
NumString(3) = "叁"
NumString(4) = "肆"
NumString(5) = "伍"
NumString(6) = "陆"
NumString(7) = "柒"
NumString(8) = "捌"
NumString(9) = "玖"
NumString(10) = "拾"
NumString(11) = "佰"
NumString(12) = "仟"
NumString(13) = "万"
NumString(14) = "拾万"
NumString(15) = "佰万"
NumString(16) = "仟万"
NumString(17) = "亿"
NumString(18) = "拾亿"
NumString(19) = "佰亿"
NumString(20) = "仟亿"
digitToUper = ""
If IsNull(lAccount) Then Exit Function
If Trim(lAccount) = "" Then Exit Function
If Not IsNumeric(lAccount) Then Exit Function
sStrPara = lAccount
If CCur(sStrPara) < 0 Then
ifFuzhi = True
sStrPara = Mid(sStrPara, 2)
End If
sStrPara = CStr(Format(CCur(sStrPara), "##0.00"))
DotPos = InStr(1, sStrPara, ".")
If DotPos = 0 Then
XiaoShuPart = ""
Else
XiaoShuPart = Mid(sStrPara, DotPos + 1)
If Len(XiaoShuPart) > 2 Then
XiaoShuPart = Left(XiaoShuPart, 2)
End If
End If
If XiaoShuPart <> "" Then
If CInt(XiaoShuPart) = 0 Then
XiaoShuPart = "整"
Else
tempStr = Mid(XiaoShuPart, 1, 1)
ShuZi = CInt(tempStr)
DaXie = NumString(ShuZi)
If ShuZi <> 0 Then DaXie = DaXie & "角"
If Len(XiaoShuPart) > 1 Then
tempStr = Mid(XiaoShuPart, 2, 1)
ShuZi = CInt(tempStr)
If ShuZi <> 0 Then
DaXie = DaXie & NumString(ShuZi) & "分"
End If
End If
XiaoShuPart = DaXie
End If
Else
XiaoShuPart = "整"
End If
If DotPos <> 0 Then
ZhengShuPart = Left(sStrPara, DotPos - 1)
Else
ZhengShuPart = sStrPara
End If
If CDbl(ZhengShuPart) = 0 Then
If XiaoShuPart <> "整" Then
digitToUper = XiaoShuPart
Else
digitToUper = NumString(0)
End If
Exit Function
Else
LastZero = False
AllZero = True
DaXie = "元"
ifWan = False
Length = Len(ZhengShuPart) + 1
For i = Len(ZhengShuPart) To 1 Step -1
tempStr = Mid(ZhengShuPart, i, 1)
ShuZi = CInt(tempStr)
If ShuZi = 0 Then
If Not AllZero And Not LastZero Then
DaXie = NumString(0) & DaXie
End If
If Length - i = 1 And XiaoShuPart <> "整" Then
If Mid(XiaoShuPart, 1, 1) <> NumString(0) Then DaXie = DaXie & NumString(0)
End If
LastZero = True
Else
AllZero = False
LastZero = False
If Length - i = 2 Then DaXie = NumString(10) & DaXie
If Length - i = 3 Then DaXie = NumString(11) & DaXie
If Length - i = 4 Then DaXie = NumString(12) & DaXie
If Length - i >= 5 And Not ifWan Then
DaXie = NumString(13) & DaXie
ifWan = True
End If
If ifWan Then
If Length - i - 5 = 1 Then DaXie = NumString(10) & DaXie
If Length - i - 5 = 2 Then DaXie = NumString(11) & DaXie
If Length - i - 5 = 3 Then DaXie = NumString(12) & DaXie
If Length - i - 5 >= 4 And Not ifYi Then
DaXie = NumString(17) & DaXie
ifYi = True
End If
If ifYi Then
If Length - i - 5 - 4 = 1 Then DaXie = NumString(10) & DaXie
If Length - i - 5 - 4 = 2 Then DaXie = NumString(11) & DaXie
If Length - i - 5 - 4 = 3 Then DaXie = NumString(12) & DaXie
If Length - i - 5 - 4 = 4 Then DaXie = NumString(13) & DaXie
If Length - i - 5 - 4 = 5 Then DaXie = NumString(14) & DaXie
If Length - i - 5 - 4 = 6 Then DaXie = NumString(15) & DaXie
If Length - i - 5 - 4 = 7 Then DaXie = NumString(16) & DaXie
End If
End If
DaXie = NumString(ShuZi) & DaXie
End If
Next
If Len(DaXie) > 2 Then
tempStr = Mid(DaXie, 1, 2)
If tempStr = NumString(1) & NumString(10) Then
DaXie = Mid(DaXie, 2)
End If
End If
If ifFuzhi Then
DaXie = "负" & DaXie
End If
ZhengShuPart = DaXie
End If
digitToUper = ZhengShuPart & XiaoShuPart
End Function
www.pchome.net
下载行业软件