Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing Checks, Need to convert numbers to text

Status
Not open for further replies.

MagnusFox

IS-IT--Management
Jan 12, 2001
51
US
I pass my form the numeric field [Total]. I need to print out the words that represent that field in a separate field.

Example:
[Total] = 1234

Filed1 would display "1234"
Field2 would display "One Thousand Two Hundred Thirty Four"
so my question is how do I get 1234 to display as One Thousand Two Hundred Thirty Four?

Thanks much,
Magnus
 
Magnus --

You can should be able to find an OCX or a module on the web that will do this conversion for you.

A quick search of revealed a couple of items that might work. On the CNet home page, click Downloads, then click Software Development, then do a search on the word "numeric". One of the found items was a free OCX called Numeric to Verbose 1.0. You will probably find other similar components by searching on various key words.

Hope this helps -- WB
 
Public Function CurrencyText(CurrencyValue As Currency) As String
If Sgn(CurrencyValue) = -1 Then
CurrencyText = "Negative Number Invalid!!!"
End If
Dim Cents As Integer
Dim Dollars As String
Dim Units(9) As String
Dim Teens(9) As String
Dim Tens(9) As String

Units(0) = "ZERO": Teens(0) = "TEN": Tens(0) = ""
Units(1) = "ONE": Teens(1) = "ELEVEN": Tens(1) = "TEN"
Units(2) = "TWO": Teens(2) = "TWELVE": Tens(2) = "TWENTY"
Units(3) = "THREE": Teens(3) = "THIETEEN": Tens(3) = "THIRTY"
Units(4) = "FOUR": Teens(4) = "FOURTEEN": Tens(4) = "FORTY"
Units(5) = "FIVE": Teens(5) = "FIFTEEN": Tens(5) = "FIFTY"
Units(6) = "SIX": Teens(6) = "SIXTEEN": Tens(6) = "SIXTY"
Units(7) = "SEVEN": Teens(7) = "SEVENTEEN": Tens(7) = "SEVENTY"
Units(8) = "EIGHT": Teens(8) = "EIGHTEEN": Tens(8) = "EIGHTY"
Units(9) = "NINE": Teens(9) = "NINETEEN": Tens(9) = "NINETY"

Cents = (CurrencyValue - Int(CurrencyValue)) * 100
Dollars = Format(Int(CurrencyValue), "000000000")

Select Case Cents
Case 0
CurrencyText = " NO/100 DOLLARS "
Case Else
CurrencyText = Format(Cents, " 00") & "/100 DOLLARS "
End Select
Select Case Mid(Dollars, Len(Dollars) - 1, 1) 'tens digit
Case "1" 'last two digits are teens
CurrencyText = Teens(Val(Right(Dollars, 1))) & " AND" & CurrencyText
Case Else
CurrencyText = Tens(Val(Mid(Dollars, Len(Dollars) - 1, 1))) & _
IIf(Right(Dollars, 1) > 0, "-" & Units(Val(Right(Dollars, 1))), " " & Units(Val(Right(Dollars, 1)))) & " AND" & CurrencyText
End Select
If Mid(Dollars, Len(Dollars) - 2, 1) <> &quot;0&quot; Then 'hundreds digit
CurrencyText = Units(Val(Mid(Dollars, Len(Dollars) - 2, 1))) & &quot; HUNDRED &quot; & CurrencyText
End If
Dollars = Left(Dollars, Len(Dollars) - 3) 'trim off hundreds,tens, & units
If Right(Dollars, 3) <> &quot;000&quot; Then 'no thousands
Select Case Mid(Dollars, Len(Dollars) - 1, 1) 'ten thousand digit
Case &quot;1&quot; 'last two digits are teens
CurrencyText = Teens(Val(Right(Dollars, 1))) & &quot; THOUSAND &quot; & CurrencyText
Case Else
CurrencyText = Tens(Val(Mid(Dollars, Len(Dollars) - 1, 1))) & &quot; &quot; & _
Units(Val(Right(Dollars, 1))) & &quot; THOUSAND &quot; & CurrencyText
End Select
If Mid(Dollars, Len(Dollars) - 2, 1) <> &quot;0&quot; Then 'thousands digit
CurrencyText = Units(Val(Mid(Dollars, Len(Dollars) - 2, 1))) & &quot; HUNDRED &quot; & CurrencyText
End If
End If
Dollars = Left(Dollars, Len(Dollars) - 3) 'trim off thousands...leave millions
If Right(Dollars, 3) <> &quot;000&quot; Then 'no millions
Select Case Mid(Dollars, Len(Dollars) - 1, 1) 'ten million digit
Case &quot;1&quot; 'last two digits are teens
CurrencyText = Teens(Val(Right(Dollars, 1))) & &quot; MILLION &quot; & CurrencyText
Case Else
CurrencyText = Tens(Val(Mid(Dollars, Len(Dollars) - 1, 1))) & &quot; &quot; & _
Units(Val(Right(Dollars, 1))) & &quot; MILLION &quot; & CurrencyText
End Select
If Mid(Dollars, Len(Dollars) - 2, 1) <> &quot;0&quot; Then 'millions digit
CurrencyText = Units(Val(Mid(Dollars, Len(Dollars) - 2, 1))) & &quot; HUNDRED &quot; & CurrencyText
End If
End If
End Function



Use it like this. If total is your variable.
Text1 = CurrencyText(total)

David Paulson


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top