Function RMB ( ls as Currency) as string
Dim dblAmount as Double
Dim MA1(14) as string ,MA2(14) as string, x as string, y as string, Y1, LML As number
Dim NS as number, NS0 As Currency
Dim i As number
dblAmount = CDbl(ls)
MA1( 1) = "分"
MA1( 2) = "角"
MA1( 3) = "元"
MA1( 4) = "拾"
MA1(5) = "佰"
MA1(6) = "仟"
MA1(7) = "万"
MA1(8) = "拾"
MA1(9) = "佰"
MA1(10) = "仟"
MA1(11) = "亿"
MA1(12) = "拾"
MA1(13) = "佰"
MA1(14) = "仟"
MA2(1) = "壹"
MA2(2) = "贰"
MA2(3) = "叁"
MA2(4) = "肆"
MA2(5) = "伍"
MA2(6) = "陆"
MA2(7) = "柒"
MA2(8) = "捌"
MA2(9) = "玖"
x = "整"
y = replace(Trim(CStr(dblAmount)),",","")
If InStr(y, ".") = 0 Then
y = y + "00"
Else
LML = InStr(y,".")
y = Left(y, LML - 1) + Left(Mid(y, LML + 1) + "00", 2)
End If
NS0 = 0
LML =Len(y)
For i = 1 To LML
Y1 = Mid(y, LML - i + 1, 1)
NS = val(Y1)
If NS <> 0 Then
x =MA2(NS) + MA1(i) +x
ElseIf MA1(i) = "元" Or MA1(i) = "万" Then
x = MA1( i) + x
End If
If i <= 2 Then
NS0 = 0
ElseIf NS = 0 And NS0 <> 0 Then
x = "零" + x
NS0 = 0
ElseIf i = 6 Then
NS0 = 0
Else
NS0 = NS
End If
Next i
If dblAmount < 0 Then
x = "负" + Right(x, Len(x) - 1)
End If
If x = "元整" Then
x = "零" + x
End If
RMB = x
End Function