‘Rem 转为大写字串
Private Function toBBig(Money As Variant) As String
Dim LenZ As Integer ‘正数部分位数
Dim i As Integer ‘
Dim s As String ‘
Dim M As String ‘格式化后金额字符串
On Error GoTo BigMoney
‘格式化
Money = Trim(Format(Money, “#0.00”))
‘负值情况
If Val(Money) < 0 Then
M = Right(Money, Len(Money) - 1)
'0值情况
ElseIf Val(Money) = 0 Then
toBBig = "零元整"
Exit Function
'正值情况
Else
M = Money
End If
'正数部分位数
LenZ = Len(M) - 3
'将金额数据格式成15位(ABCDEFGHIJKL.MN)型
M = Space(12 - LenZ) & M
If LenZ > 12 Then
toBBig = ” ”
Exit Function
End If
For i = 12 – LenZ + 1 To 15
s = Mid(M, i, 1)
Select Case i
Case 1, 5, 9 ‘千亿、千万、千位
If Val(s) > 0 Then
toBBig = toBBig & toBig(Val(s)) & toBig(15) ‘千
Else
If Right(toBBig, 1) <> “零” Then
toBBig = toBBig & toBig(0) ‘零
End If
End If
Case 2, 6, 10 ‘百亿、百万、百位
If Val(s) > 0 Then
toBBig = toBBig & toBig(Val(s)) & toBig(14) ‘百
Else
If Right(toBBig, 1) <> “零” Then
toBBig = toBBig & toBig(0)
End If
End If
Case 3, 7, 11 ‘十亿、十万、十位
If Val(s) > 0 Then
toBBig = toBBig & toBig(Val(s)) & toBig(13) ‘十
ElseIf Right(toBBig, 1) <> “零” Then
toBBig = toBBig & toBig(0)
End If
Case 4, 8, 12 ‘亿、万、个 位
If i = 12 Then
If Val(s) > 0 Then
toBBig = toBBig & toBig(Val(s)) & toBig(12) ‘元
ElseIf Right(toBBig, 1) = “零” Then
toBBig = Left(toBBig, Len(toBBig) – 1) & toBig(12)
Else
toBBig = toBBig & toBig(12)
End If
ElseIf i = 8 Then
If Val(s) > 0 Then
toBBig = toBBig & toBig(Val(s)) & toBig(16) ‘万
ElseIf Right(toBBig, 1) = “零” Then
If Right(Left(toBBig, Len(toBBig) – 1), 1) <> “亿” Then
toBBig = Left(toBBig, Len(toBBig) – 1) & toBig(16)
End If
Else
toBBig = toBBig & toBig(16)
End If
ElseIf i = 4 Then ‘亿
If Val(s) > 0 Then
toBBig = toBBig & toBig(Val(s)) & toBig(17)
ElseIf Right(toBBig, 1) = “零” Then
toBBig = Left(toBBig, Len(toBBig) – 1) & toBig(17)
Else
toBBig = toBBig & toBig(17)
End If
End If
Case 14
If Val(s) > 0 Then
toBBig = toBBig & toBig(Val(s)) & toBig(11) ‘角
Else
toBBig = toBBig & toBig(0)
End If
Case 15
If Val(s) > 0 Then
toBBig = toBBig & toBig(Val(s)) & toBig(10) ‘分
ElseIf Right(toBBig, 1) = “零” Then
toBBig = Left(toBBig, Len(toBBig) – 1)
End If
End Select
Next i
If Right(toBBig, 1) <> “分” Then
toBBig = toBBig & toBig(18) ‘整
End If
If Val(Money) < 0 Then toBBig = toBig(-1) & toBBig '负 End If Exit Function BigMoney: toBBig = "" End Function Rem 转为大写字符 Private Function toBig(Value As Integer, Optional small As Boolean = False, Optional week As Boolean = False) As String If small Then Select Case Value Case 0 toBig = IIf(week, "日", "○") Case 1 toBig = "一" Case 2 toBig = "二" Case 3 toBig = "三" Case 4 toBig = "四" Case 5 toBig = "五" Case 6 toBig = "六" Case 7 toBig = IIf(week, "日", "七") Case 8 toBig = "八" Case 9 toBig = "九" End Select Else Select Case Value Case -1 toBig = "负" Case 0 toBig = "零" Case 1 toBig = "壹" Case 2 toBig = "贰" Case 3 toBig = "叁" Case 4 toBig = "肆" Case 5 toBig = "伍" Case 6 toBig = "陆" Case 7 toBig = "柒" Case 8 toBig = "捌" Case 9 toBig = "玖" Case 10 toBig = "分" Case 11 toBig = "角" Case 12 toBig = "元" Case 13 toBig = "拾" Case 14 toBig = "佰" Case 15 toBig = "仟" Case 16 toBig = "万" Case 17 toBig = "亿" Case 18 toBig = "整" End Select End If End Function