Public 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
this function is not my own. was taken from https://forum.xojo.com/23567-convertir-numeros-a-letras/
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.