# Function to convert currency to string

I seem to remember seeing some code maybe this forum or the old realstudio forum that can convert an amount to the string equivalent like the bank cheque (check).

100 would be ‘one hundred’
297 would be ‘two hundred ninety seven’

Simon Berridge had posted that in Spanish :

[quote]Simon Berridge Jun 24 Europe (Wiltshire, UK)
Try this:
[/quote]

[code]Function NumberToWords(number As Int64) As String

If number = 0 Then Return “Zero”
If number < 0 Then Return "Minus " + NumberToWords(Abs(number))

Dim words As String

If (number \ 1000000000) > 0 Then
words = words + NumberToWords(number/ 1000000000) + " Billion "
number = number Mod 1000000000
End

If (number \ 1000000) > 0 Then
words = words + NumberToWords(number/ 1000000) + " Million "
number = number Mod 1000000
End

If (number \ 1000) > 0 Then
words = words + NumberToWords(number/ 1000) + " Thousand "
number = number Mod 1000
End

If (number \ 100) > 0 Then
words = words + NumberToWords(number/ 100) + " Hundred "
number = number Mod 100
End

If number > 0 Then
Dim aUnits() As String= Array(“Zero”, “One”, “Two”, “Three”, “Four”, “Five”, “Six”, “Seven”, “Eight”, “Nine”, “Ten”, _
“Eleven”, “Twelve”, “Thirteen”, “Fourteen”, “Fifteen”, “Sixteen”, “Seventeen”, “Eighteen”, “Nineteen”)
Dim aTens() As String= Array(“Zero”, “Ten”, “Twenty”, “Thirty”, “Forty”, “Fifty”, “Sixty”, “Seventy”, _
“Eighty”, “Ninety”)

``````If words <> "" Then words= words+ "and "

If number < 20 Then
words = words+ aUnits(number)
Else
words = words + aTens(number/ 10)
If (number Mod 10) > 0 Then words = words+ "-" + aUnits(number Mod 10)
End
``````

End

Return words.Trim

End Function[/code]

thanks… will try it out