Here are the rules for expressing monetary units in the EU
Sub NumberSuffix(N As Double) As String
If N < 0 Then
Return "-" & NumberSuffix(-N)
End If
Dim Suffix() As String = Array As String("", "k", "M", "B", "T")
'''Dim Suffix() As String = Array As String("", " Thousand", " Million", " Billion", " Trillion")
Dim Thousands As Int = 0
Do While N >= 1000 And Thousands < Suffix.Length - 1
Thousands = Thousands + 1
N = N / 1000
Loop
If Thousands = 0 Then
'2 decimal places per example of monetary amount including cents
Return NumberFormat2(N, 1, 2, 2, False)
End If
'sufficient decimal places for precision required
Dim MaxDecimalPlaces As Int = 0
Do While MaxDecimalPlaces < 5 'absolute maximum 5 decimal places
Dim RelativeError As Double = Abs(N - Round2(N, MaxDecimalPlaces)) / N
If RelativeError < 0.007 Then 'eg 0.7% (or whatever precision you need)
Exit
End If
MaxDecimalPlaces = MaxDecimalPlaces + 1
Loop
Return NumberFormat2(N, 1, 0, MaxDecimalPlaces, False) & Suffix(Thousands)
End Sub
Looks like you might also be headed towards something like this:I need something to convert money figures to their equivalents just like one would convert sizes to MB etc.
Is there a general rule across the board for doing this. For example, $53,447,890.00, would be $53M.
For Each N In Array As Int(53447890, 53447090, 53440090, 53400090, 53000090)
Log(N & " is: " & NumberToWords(N))
Next
53447890 is: Fifty-Three Million, Four Hundred and Forty-Seven Thousand, Eight Hundred and Ninety
53447090 is: Fifty-Three Million, Four Hundred and Forty-Seven Thousand and Ninety
53440090 is: Fifty-Three Million, Four Hundred and Forty Thousand and Ninety
53400090 is: Fifty-Three Million, Four Hundred Thousand and Ninety
53000090 is: Fifty-Three Million and Ninety