我的笨方法:
Dim Big$(10)
Big(0) = "零": Big(1) = "壹": Big(2) = "贰": Big(3) = "叁": Big(4) = "肆": Big(5) = "伍": Big(6) = "陆": Big(7) = "柒": Big(8) = "捌": Big(9) = "玖"
Dim Little$(1 To 8), Nil$(1 To 2)
'/小数点左边数,小数点后边数
Dim Myint As Integer, Mystr$
Mystr = Val(Rmb)
Myint = InStr(Mystr, ".")
'到小数点有几位数,包括小数点
Dim ForntDot$
'小数点左边数字
Dim SinceDot$
'小数点后的数字
If Myint = 0 Then
'
只有个位数且无小数点
ForntDot = Mystr
Else
' 有小数点
SinceDot = Right$(Mystr, (Len(Mystr) - Myint))
'小数点后的数字
ForntDot = Left$(Mystr, Myint - 1)
'小数点左边数据
End If
Dim n%
'小数点后边数字有几位数
n = Len(SinceDot)
If n = 0 Then
Nil(1) = "": Nil(2) = ""
ElseIf n = 1 Then
Nil(1) = Left$(SinceDot, 1): Nil(2) = ""
ElseIf n > 1 Then
Nil(1) = Left$(SinceDot, 1): Nil(2) = Right$(Left$(SinceDot, 2), 1)
Else
End If
Dim m%
'小数点左边数字有几位数
m = Len(ForntDot)
If m > 8 Then
' MsgBox "抱歉!本系统只能记录到千万位。"
Exit Sub
End If
For i = m + 1 To 8
Little(i) = ""
'保证小数点左边数字有8位数
Next i
Dim Dstr$
'过渡用瓶子
For i = m To 1 Step -1
'个位数是1位,十位数是2位,…,第八位数是千万
Dstr = Left$(ForntDot, m + 1 - i)
Little(i) = Right$(Dstr, 1)
Next i
Dim Mystr1$, Mystr2$
'转换成大写
Mystr1 = IIf(Little(8) = "", "", Big(Val(Little(8))) & "仟")
If Little(7) = "" Then
Mystr1 = Mystr1
ElseIf Little(7) = "0" Then
If Little(8) <> "0" And (Little(6) <> "0" Or Little(5) <> "0") Then
Mystr1 = Mystr1 & Big(Val(Little(7)))
ElseIf Little(8) <> "0" And (Little(6) = "0" Or Little(5) = "0") Then
Mystr1 = Mystr1
ElseIf Little(8) = "0" And (Little(6) = "0" Or Little(5) = "0") Then
Mystr1 = Mystr1
ElseIf Little(8) = "0" And (Little(6) <> "0" Or Little(5) <> "0") Then
Mystr1 = Mystr1
Else
End If
ElseIf Little(7) <> "0" Then
Mystr1 = Mystr1 & Big(Val(Little(7))) & "佰"
Else
End If
If Little(6) = "" Then
Mystr1 = Mystr1
ElseIf Little(6) = "0" Then
If Little(7) <> "0" And (Little(5) <> "0") Then
Mystr1 = Mystr1 & Big(Val(Little(6)))
ElseIf Little(7) <> "0" And (Little(5) = "0") Then
Mystr1 = Mystr1
ElseIf Little(7) = "0" And (Little(5) = "0") Then
Mystr1 = Mystr1
ElseIf Little(7) = "0" And (Little(5) <> "0") Then
Mystr1 = Mystr1
Else
End If
ElseIf Little(6) <> "0" Then
Mystr1 = Mystr1 & Big(Val(Little(6))) & "拾"
Else
End If
If Little(5) = "" Then
Mystr1 = Mystr1
ElseIf Little(5) = "0" Then
If Little(6) <> "0" And (Little(4) <> "0") Then
Mystr1 = Mystr1 & "万"
ElseIf Little(6) <> "0" And (Little(4) = "0") Then
Mystr1 = Mystr1 & "万"
ElseIf Little(6) = "0" And (Little(4) = "0") Then
Mystr1 = Mystr1 & "万"
ElseIf Little(6) = "0" And (Little(4) <> "0") Then
Mystr1 = Mystr1 & "万"
Else
End If
ElseIf Little(5) <> "0" Then
Mystr1 = Mystr1 & Big(Val(Little(5))) & "万"
Else
End If
If Little(4) = "" Then
Mystr1 = Mystr1
ElseIf Little(4) = "0" Then
If Little(5) <> "0" And (Little(3) <> "0" Or Little(2) <> "0" Or Little(1) <> "0") Then
Mystr1 = Mystr1 & Big(Val(Little(4)))
ElseIf Little(5) <> "0" And (Little(3) = "0" Or Little(2) = "0" Or Little(1) = "0") Then
Mystr1 = Mystr1
ElseIf Little(5) = "0" And (Little(3) = "0" And Little(2) = "0" And Little(1) = "0") Then
Mystr1 = Mystr1
ElseIf Little(5) = "0" And (Little(3) = "0" Or Little(2) = "0" Or Little(1) = "0") Then
Mystr1 = Mystr1 & Big(Val(Little(4)))
ElseIf Little(5) = "0" And Little(3) = "0" And (Little(2) <> "0" Or Little(1) <> "0") Then
Mystr1 = Mystr1 & Big(Val(Little(4)))
ElseIf Little(5) = "0" And (Little(3) <> "0" Or Little(2) <> "0" Or Little(1) <> "0") Then
Mystr1 = Mystr1 & Big(Val(Little(4)))
Else
End If
ElseIf Little(4) <> "0" Then
Mystr1 = Mystr1 & Big(Val(Little(4))) & "仟"
Else
End If
If Little(3) = "" Then
Mystr1 = Mystr1
ElseIf Little(3) = "0" Then
If Little(4) <> "0" And (Little(2) <> "0" Or Little(1) <> "0") Then
Mystr1 = Mystr1 & Big(Val(Little(3)))
ElseIf Little(4) <> "0" And (Little(2) = "0" Or Little(1) = "0") Then
Mystr1 = Mystr1
ElseIf Little(4) = "0" And (Little(2) = "0" Or Little(1) = "0") Then
Mystr1 = Mystr1
ElseIf Little(4) = "0" And (Little(2) <> "0" Or Little(1) <> "0") Then
Mystr1 = Mystr1
Else
End If
ElseIf Little(3) <> "0" Then
Mystr1 = Mystr1 & Big(Val(Little(3))) & "佰"
Else
End If
If Little(2) = "" Then
Mystr1 = Mystr1
ElseIf Little(2) = "0" Then
If Little(3) <> "0" And (Little(1) <> "0") Then
Mystr1 = Mystr1 & Big(Val(Little(2)))
ElseIf Little(3) <> "0" And (Little(1) = "0") Then
Mystr1 = Mystr1
ElseIf Little(4) = "0" And (Little(1) = "0") Then
Mystr1 = Mystr1
ElseIf Little(3) = "0" And (Little(1) <> "0") Then
Mystr1 = Mystr1
Else
End If
ElseIf Little(2) <> "0" Then
Mystr1 = Mystr1 & Big(Val(Little(2))) & "拾"
Else
End If
If Little(1) = "" Then
Mystr1 = Mystr1
ElseIf Little(1) = "0" Then
If Little(2) <> "0" And Little(2) <> "" Then
Mystr1 = Mystr1 & "圆"
ElseIf Little(2) = "" Then
Mystr1 = Mystr1
ElseIf Little(2) = "0" Then
Mystr1 = Mystr1 & "圆"
Else
End If
ElseIf Little(1) <> "0" Then
Mystr1 = Mystr1 & Big(Val(Little(1))) & "圆"
Else
End If
If (Nil(1) = "" And Nil(2) = "") Or (Nil(1) = "0" And Nil(2) = "0") Then
Mystr2 = "整"
Else
If Nil(1) <> "" And Nil(2) = "" Then Mystr2 = Big(Val(Nil(1))) & "角整"
If Nil(1) <> "" And Nil(2) <> "" Then Mystr2 = Big(Val(Nil(1))) & "角" & Big(Val(Nil(2))) & "分"
If Nil(1) <> "" And Nil(2) = "0" Then Mystr2 = Big(Val(Nil(1))) & "角整"
If Nil(1) = "0" And Nil(2) = "" Then Mystr2 = "整"
If Nil(1) = "0" And Nil(2) <> "" Then Mystr2 = Big(Val(Nil(1))) & Big(Val(Nil(2))) & "分"
End If
T_Big = Mystr1 & Mystr2
'转换完成,显示T_Big就可以了
If m >= 2 And Left$(ForntDot, 1) = "0" Then
'十位数以上左边第一位为0
MsgBox "老兄:没这样表述的,请重新输入吧!"
End If
T_Big = Mystr1 & Mystr2
If m >= 2 And Left$(ForntDot, 1) = "0" Then MsgBox "老兄:没这样表述的,请重新输入吧!"
'十位数以上左边第一位为0