<P>Function RMBpro(SourceNumber As Double) As String
'Junhui's Macro2002-9-2</P>
<P>
ChineseString1 = "壹贰叁肆伍陆柒捌玖"
ChineseString2 = "仟佰拾亿仟佰拾万仟佰拾圆角分"
OutString = ""
NumberString = Trim(Str(Int(Application.Round(SourceNumber * 100, 0))))
CNT0001 = 15 - Len(NumberString)
CNT0002 = 1
TenThousandYN = 0
Do While CNT0001 <= 14
SubNumber = Val(Mid(NumberString, CNT0002, 1))
If SubNumber <> 0 Then
If CNT0001 = 5 Or CNT0001 = 6 Or CNT0001 = 7 Then
TenThousandYN = 1
End If
RMBsubstr = Mid(ChineseString1, SubNumber, 1)
OutString = OutString & RMBsubstr
RMBsubstr = Mid(ChineseString2, CNT0001, 1)
OutString = OutString & RMBsubstr
Else
If CNT0001 = 4 Then
If Not IsEmpty(OutString) Then
OutString = OutString & "亿"
End If
End If
If CNT0001 = 8 Then
If TenThousandYN = 1 Then
OutString = OutString & "万"
End If
End If
If CNT0001 = 12 Then
If Not IsEmpty(OutString) Then
OutString = OutString & "圆"
End If
End If
If CNT0001 < 14 And CNT0001 <> 12 Then '20.30的大写为贰拾圆叁角整
'If CNT0001 < 14 Then '20.30的大写为贰拾圆零叁角整,和用上一句有区别
If Mid(NumberString, CNT0002 + 1, 1) <> "0" Then
OutString = OutString & "零"
End If
End If
If CNT0001 = 14 And SourceNumber <> 0 Then
OutString = OutString & "整"
End If
End If
CNT0001 = CNT0001 + 1
CNT0002 = CNT0002 + 1
Loop</P>
<P>RMBpro = OutString</P>
<P>End Function
</P>这个VBA代码可以处理千亿位的数,足够了。
[此贴子已经被作者于2004-6-1 18:25:57编辑过] |