VBA大写函数
Public Function DaXie(ByVal Num As Double) ' 人民币中文大写函数
Place = "分角元拾佰仟万拾佰仟亿拾佰仟万"
Dn = "壹贰叁肆伍陆柒捌玖"
D1 = "整零元零零零万零零零亿零零零万"
If Num < 0 Then FuHao = "(负)"
Num = Format(Abs(Num), "###0.00") * 100
If Num > 999999999999999# Then: DaXie = "数字超出转换范围!!": Exit Function
If Num = 0 Then: DaXie = "零元零分": Exit Function
NumA = Trim(Str(Num))
NumLen = Len(NumA)
For J = NumLen To 1 Step -1 ' 数字转换过程
Temp = Val(Mid(NumA, NumLen - J + 1, 1))
If Temp <> 0 Then ' 非零数字转换
NumC = NumC & Mid(Dn, Temp, 1) & Mid(Place, J, 1)
Else ' 数字零的转换
If Right(NumC, 1) <> "零" Then
NumC = NumC & Mid(D1, J, 1)
Else
Select Case J ' 特殊数位转换
Case 1
NumC = Left(NumC, Len(NumC) - 1) & Mid(D1, J, 1)
Case 3, 11
NumC = Left(NumC, Len(NumC) - 1) & Mid(D1, J, 1) & "零"
Case 7
If Mid(NumC, Len(NumC) - 1, 1) <> "亿" Then
NumC = Left(NumC, Len(NumC) - 1) & Mid(D1, J, 1) & "零"
End If
Case Else
End Select
End If
End If
Next
DaXie = FuHao & Trim(NumC)
End Function
Place = "分角元拾佰仟万拾佰仟亿拾佰仟万"
Dn = "壹贰叁肆伍陆柒捌玖"
D1 = "整零元零零零万零零零亿零零零万"
If Num < 0 Then FuHao = "(负)"
Num = Format(Abs(Num), "###0.00") * 100
If Num > 999999999999999# Then: DaXie = "数字超出转换范围!!": Exit Function
If Num = 0 Then: DaXie = "零元零分": Exit Function
NumA = Trim(Str(Num))
NumLen = Len(NumA)
For J = NumLen To 1 Step -1 ' 数字转换过程
Temp = Val(Mid(NumA, NumLen - J + 1, 1))
If Temp <> 0 Then ' 非零数字转换
NumC = NumC & Mid(Dn, Temp, 1) & Mid(Place, J, 1)
Else ' 数字零的转换
If Right(NumC, 1) <> "零" Then
NumC = NumC & Mid(D1, J, 1)
Else
Select Case J ' 特殊数位转换
Case 1
NumC = Left(NumC, Len(NumC) - 1) & Mid(D1, J, 1)
Case 3, 11
NumC = Left(NumC, Len(NumC) - 1) & Mid(D1, J, 1) & "零"
Case 7
If Mid(NumC, Len(NumC) - 1, 1) <> "亿" Then
NumC = Left(NumC, Len(NumC) - 1) & Mid(D1, J, 1) & "零"
End If
Case Else
End Select
End If
End If
Next
DaXie = FuHao & Trim(NumC)
End Function