Public Function USD(WhatNumber)
Dim ToRead, NumString, Group, Word As String
Dim I, J As Byte, W, X, Y, Z As Double
Dim FristColum, SecondColum, ReadMetho
If WhatNumber = 0 Then
ToRead = "None"
Else
If Abs(WhatNumber) >= 1E+15 Then
ToRead = "Too long number ???"
Else
FristColum = Array("None", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eightteen", "nineteen")
SecondColum = Array("None", "None", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety")
ReadMetho = Array("None", "trillion", "billion", "million", "thousand", "dollars", "cents")
If WhatNumber < 0 Then
ToRead = "Minus" & Space(1)
Else
ToRead = Space(0)
End If
NumString = Format(Abs(WhatNumber), "##############0.00")
NumString = Right(Space(15) & NumString, 18)
For I = 1 To 6
Group = Mid(NumString, I * 3 - 2, 3)
If Group <> Space(3) Then
Select Case Group
Case "000"
If I = 5 And Abs(WhatNumber) > 1 Then
Word = "dollars" & Space(1)
Else
Word = Space(0)
End If
Case ".00"
Word = "only"
Case Else
X = Val(Left(Group, 1))
Y = Val(Mid(Group, 2, 1))
Z = Val(Right(Group, 1))
W = Val(Right(Group, 2))
If X = 0 Then
Word = Space(0)
Else
Word = FristColum(X) & Space(1) & "hundred" & Space(1)
If W > 0 And W < 21 Then
Word = Word & "and" & Space(1)
End If
End If
If I = 6 And Abs(WhatNumber) > 1 Then
Word = "and" & Space(1) & Word
End If
If W < 20 And W > 0 Then
Word = Word & FristColum(W) & Space(1)
Else
If W >= 20 Then
Word = Word & SecondColum(Y) & Space(1)
If Z > 0 Then
Word = Word & FristColum(Z) & Space(1)
End If
End If
End If
Word = Word & ReadMetho(I) & Space(1)
End Select
ToRead = ToRead & Word
End If
Next I
End If
End If
USD = UCase(Left(ToRead, 1)) & Mid(ToRead, 2)
End Function