用于将数字换汉字大写数字的函数
Function zhh(mrmbze)
Dim S_1 As String
Dim S_2 As String
Dim S_4 As String
Dim s_5 As String
Dim S_6 As String
Dim S_7 As String
Dim I As Integer
Dim tn As Single
Dim S_1 As String
Dim S_2 As String
Dim S_4 As String
Dim s_5 As String
Dim S_6 As String
Dim S_7 As String
Dim I As Integer
Dim tn As Single
S_1 = "零壹贰叁肆伍陆柒捌玖"
S_2 = "仟佰拾万仟佰拾元角分"
S_2 = "仟佰拾万仟佰拾元角分"
转自:Access中国
作者:Benjamin_luk
代码:
Option Compare Database
Option Explicit
代码:
Option Compare Database
Option Explicit
Function CWord(myNumber As Double) As String
Dim str1 As String, str2 As String, str3 As String, str4 As String, str5 As String, str6 As String, str7 As String
Dim I As Integer, J As Integer, K As Integer, L As Integer
str1 = "仟佰拾亿仟佰拾万仟佰拾元角分"
str2 = "元角分"
str3 = "零壹贰叁肆伍陆柒捌玖"
str4 = Left(Trim(Format(myNumber, "0.00")), Len(Format(myNumber, "0.00")) - 3) & Right(Trim(Format(myNumber, "0.00")), 2)
str5 = Right(Trim(Format(myNumber, "0.00")), 2)
Dim str1 As String, str2 As String, str3 As String, str4 As String, str5 As String, str6 As String, str7 As String
Dim I As Integer, J As Integer, K As Integer, L As Integer
str1 = "仟佰拾亿仟佰拾万仟佰拾元角分"
str2 = "元角分"
str3 = "零壹贰叁肆伍陆柒捌玖"
str4 = Left(Trim(Format(myNumber, "0.00")), Len(Format(myNumber, "0.00")) - 3) & Right(Trim(Format(myNumber, "0.00")), 2)
str5 = Right(Trim(Format(myNumber, "0.00")), 2)
str6 = Right(str1, Len(str4))
For I = 1 To Len(str4)
K = CDbl(Mid(str4, I, 1))
str7 = str7 & Mid(str3, K + 1, 1) & Mid(str6, I, 1)
Next I
CWord = str7 & "整"
End Function
Function ctest()
MsgBox CWord(120001.03)
End Function字符串函数中将大写转换为小写
For I = 1 To Len(str4)
K = CDbl(Mid(str4, I, 1))
str7 = str7 & Mid(str3, K + 1, 1) & Mid(str6, I, 1)
Next I
CWord = str7 & "整"
End Function
Function ctest()
MsgBox CWord(120001.03)
End Function字符串函数中将大写转换为小写
S_4 = Ltrim(Str(Nz(Int(mrmbze * 100))))
If Len(S_4) > 10 And mrmbze > 0 And mrmbze < 99999999.99 Then
tn = Int(mrmbze * 100) / 100
If mrmbze - tn >= 0.005 Then
tn = tn + 0.01
End If
S_4 = Ltrim(Str(tn * 100))
S_4 = Ltrim(Str(tn * 100))
End If
If Len(S_4) > 10 Or mrmbze < 0 Then
zhh = "ERROR!!! The number to be transferred CANNOT be negative and must be less than 99999999.99"
Else
S_4 = String(10 - Len(S_4), " ") + S_4
I = 1
zhh = ""
Do While I <= 10
s_5 = Mid(S_4, I, 1)
If s_5 <> " " Then
S_6 = Mid(S_1, Val(s_5) + 1, 1)
S_7 = Mid(S_2, I, 1)
If s_5 = "0" And I <> 4 And I <> 8 Then
S_7 = ""
End If
If (Mid(S_4, I, 2) = "00") Or (s_5 = "0" And (I = 4 Or I = 8 Or I = 10)) Then
I = 1
zhh = ""
Do While I <= 10
s_5 = Mid(S_4, I, 1)
If s_5 <> " " Then
S_6 = Mid(S_1, Val(s_5) + 1, 1)
S_7 = Mid(S_2, I, 1)
If s_5 = "0" And I <> 4 And I <> 8 Then
S_7 = ""
End If
If (Mid(S_4, I, 2) = "00") Or (s_5 = "0" And (I = 4 Or I = 8 Or I = 10)) Then
S_6 = ""
End If
zhh = zhh + S_6 + S_7
If Mid(S_4, I, 1) = "0" And Mid(S_4, I + 1, 1) <> "0" And (I = 4 Or I = 8) Then
zhh = zhh + "零"
End If
End If
I = I + 1
Loop
If s_5 = "0" Then
zhh = zhh + "整"
End If
End If
End If
zhh = zhh + S_6 + S_7
If Mid(S_4, I, 1) = "0" And Mid(S_4, I + 1, 1) <> "0" And (I = 4 Or I = 8) Then
zhh = zhh + "零"
End If
End If
I = I + 1
Loop
If s_5 = "0" Then
zhh = zhh + "整"
End If
End If
If zhh Like "*" & "元零" & "*" & "角" & "*" Then
zhh = Replace(zhh, "元零", "元")
End If
zhh = Replace(zhh, "元零", "元")
End If
End Function
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论