|
论坛上找的数字转大写函数,根据自己需要,增加了部分功能,也算是狗尾续貂吧,与大家分享.
Public Function URmb(ByVal Money As Double) As String '取得数字的汉字大写
Dim Intlen As Integer
Dim i As Integer
Dim strMoney As String
Dim bnlFu As Boolean
If Money < 0 Then '如果金额小于零,则标志变量为"真"
bnlFu = True
End If
Money = Abs(Money) '取绝对值
If Money < 0.005 Then '如果小于5厘,则以零计
URmb = "RMB零分"
Exit Function
End If
If Money >= 0.005 And Money < 0.01 Then '5厘和壹分之间以壹分计
If bnlFu = False Then
URmb = "RMB壹分"
Else
URmb = "RMB负壹分"
End If
Exit Function
End If
strMoney = Format(Money, "#.##") * 100
Intlen = Len(strMoney)
If Intlen > 14 Then
URmb = Format(Money, "#.##")
Exit Function
End If
For i = 1 To Intlen
URmb = Mid("零壹贰叁肆伍陆柒捌玖", Mid(strMoney, Intlen + 1 - i, 1) + 1, 1) _
& Mid("分角元拾佰仟万拾佰仟亿拾佰仟", i, 1) & URmb
Next
If bnlFu = True Then '加上负数标记
URmb = "RMB负" & URmb
Else
URmb = "RMB" & URmb
End If
End Function
[ 本帖最后由 rcylbx 于 2008-7-7 16:40 编辑 ] |
|