Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function NumToWords(ByVal MyNumber As Double, ByVal CurrencyName As String) As String
- Dim Units As String
- Dim TempStr As String
- Dim Count As Integer
- Dim UnitsDigit As String
- Dim UnitsWords(9) As String
- ' Defines arrays for unit names
- UnitsWords(1) = "un": UnitsWords(2) = "deux": UnitsWords(3) = "trois": UnitsWords(4) = "quatre"
- UnitsWords(5) = "cinq": UnitsWords(6) = "six": UnitsWords(7) = "sept": UnitsWords(8) = "huit"
- UnitsWords(9) = "neuf"
- ' Process the number
- Count = 1
- Do While MyNumber <> ""
- UnitsDigit = Right(MyNumber, 1)
- TempStr = UnitsWords(CInt(UnitsDigit)) & " " & TempStr
- MyNumber = Left(MyNumber, Len(MyNumber) - 1)
- Count = Count + 1
- Loop
- ' Return the number in words followed by the currency
- NumToWords = Trim(TempStr) & " " & CurrencyName
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement