Check writing conver numeric amount if words [Closed]

Report
-
Hello,


Please help me with this macro for open office calc. I want in words of example : 3,234.00 to be "Three Thousand Two Hundred Thirty Four Pesos and 00/100" Below macro is just giving me Three Thousand Two Hundred Thrity Four"

Sub Main
Print NumToWords( -115628400.23 )
End Sub

Function NumToWords( ByVal nNumber As Double ) As String
Dim nPesos as Currency
cWords = ""

If nNumber < 0 Then
cWords = "Negative " + NumToWords( -1 * nNumber )

ElseIf nNumber <> Int( nNumber ) Then
cWords = NumToWords( Int( nNumber ) )
cWords = cWords + " & "
nPesos = nNumber - Int( nNumber )
Do
nPesos = nPesos * 100
nDigit = Int( nPesos )
nPesos = nPesos - nDigit

If nDigit > 0 Then
cDigitWord = nDigit
cWords = cWords + " " + cDigitWord + "/100 only"

Else
Exit Do
EndIf
Loop

ElseIf nNumber < 20 Then
Select Case nNumber
Case 0: cWords = "Zero"
Case 1: cWords = "One"
Case 2: cWords = "Two"
Case 3: cWords = "Three"
Case 4: cWords = "Four"
Case 5: cWords = "Five"
Case 6: cWords = "Six"
Case 7: cWords = "Seven"
Case 8: cWords = "Eight"
Case 9: cWords = "Nine"
Case 10: cWords = "Ten"
Case 11: cWords = "Eleven"
Case 12: cWords = "Twelve"
Case 13: cWords = "Thirteen"
Case 14: cWords = "Fourteen"
Case 15: cWords = "Fifteen"
Case 16: cWords = "Sixteen"
Case 17: cWords = "Seventeen"
Case 18: cWords = "Eighteen"
Case 19: cWords = "Nineteen"
End Select

ElseIf nNumber < 100 Then
nTensPlace = Int( nNumber / 10 )
nOnesPlace = nNumber Mod 10
Select Case nTensPlace * 10
Case 20: cWords = "Twenty"
Case 30: cWords = "Thirty"
Case 40: cWords = "Forty"
Case 50: cWords = "Fifty"
Case 60: cWords = "Sixty"
Case 70: cWords = "Seventy"
Case 80: cWords = "Eighty"
Case 90: cWords = "Ninety"
End Select
If nOnesPlace > 0 Then
cWords = cWords + " " + NumToWords( nOnesPlace )
EndIf

ElseIf nNumber < 1000 Then
nHundredsPlace = Int( nNumber / 100 )
nRest = nNumber Mod 100
cWords = NumToWords( nHundredsPlace )
cWords = cWords + " Hundred"
If nRest > 0 Then
cWords = cWords + " " + NumToWords( nRest )
EndIf

ElseIf nNumber < 1000000 Then
nThousands = Int( nNumber / 1000 )
nRest = nNumber Mod 1000
cWords = NumToWords( nThousands )
cWords = cWords + " Thousand"
If nRest > 0 Then
cWords = cWords + " " + NumToWords( nRest )
EndIf

ElseIf nNumber < 1000000000 Then
nMillions = Int( nNumber / 1000000 )
nRest = Int( nNumber Mod 1000000 )
cWords = NumToWords( nMillions )
cWords = cWords + " Million"
If nRest > 0 Then
cWords = cWords + " " + NumToWords( nRest )
EndIf

ElseIf nNumber < 1000000000000 Then
nBillions = Int( nNumber / 1000000000 )
nRest = Int( nNumber Mod 1000000000 )
cWords = NumToWords( nBillions )
cWords = cWords + " Billion"
If nRest > 0 Then
cWords = cWords + " " + NumToWords( nRest )
EndIf

ElseIf nNumber < 1000000000000000 Then
nTrillions = Int( nNumber / 1000000000000 )
nRest = Int( nNumber Mod 1000000000000 )
cWords = NumToWords( nTrillions )
cWords = cWords + " Trillion"
If nRest > 0 Then
cWords = cWords + " " + NumToWords( nRest )
EndIf

' You can follow the pattern of the Millions / Billions / Trillions
' if you need bigger numbers.

EndIf

NumToWords() = cWords
End Function