|
Function Unumber(Lnumber As Double)
Dim NumberStr$
Dim NumberLen%
Dim DotLoc1%
Dim DotLoc2%
Dim NumberStr1$
Dim NumberStr2$
If Lnumber = 0 Then
Unumber = "零元整"
Exit Function
End If
NumberStr = Application.WorksheetFunction.Text(Lnumber, "[DBnum2]")
NumberLen = Len(NumberStr)
DotLoc1 = InStr(1, NumberStr, ".", vbTextCompare)
DotLoc2 = NumberLen - DotLoc1
If DotLoc1 = 0 Then
NumberStr = NumberStr & "元整"
Else
NumberStr = Replace(NumberStr, ".", "元")
If DotLoc2 = 2 Then
NumberStr = NumberStr & "分"
If Mid(NumberStr, DotLoc1 + 1, 1) <> "零" Then
NumberStr1 = Mid(NumberStr, 1, DotLoc1 + 1) & "角"
NumberStr2 = Right(NumberStr, 2)
NumberStr = NumberStr1 & NumberStr2
End If
Else
NumberStr = NumberStr & "角整"
End If
End If
On Error Resume Next
Unumber = Replace(NumberStr, "零元", "")
End Function |
|