By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,320 Members | 2,109 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,320 IT Pros & Developers. It's quick & easy.

Assistance with Digits To Text Function

P: n/a
Need some assistance with regard to the following basic Function to
change digits to text, i.e., 295.78 = RTELG. Any suggestions or ideas
will be appreciated. Thanks.

Function dtt(Cost As Currency) As String
Select Case

Case 0
dtt = "X"
Case 1
dtt = "B"
Case 2
dtt = "R"
Case 3
dtt = "W"
Case 4
dtt = "H"
Case 5
dtt = "E"
Case 6
dtt = "K"
Case 7
dtt = "L"
Case 8
dtt = "G"
Case 9
dtt = "T"

dtt = Cost

End Select
End Function

Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Rolan wrote:
Need some assistance with regard to the following basic Function to
change digits to text, i.e., 295.78 = RTELG. Any suggestions or ideas
will be appreciated. Thanks.

Cost will come across as a number. If a number has zero cents, it will
drop the .00. So you may want to format the number first so you get the
cents value. CCur will drop the cents so I'd suggest using Format.

The last 2 letters will always be the cents value.

Function dtt(Cost As Currency) As String Dim strCost As String
Dim intFor As Integer
strCost = Format(Cost,"#,###.00")

For intFor = 1 to len(strCost)
'in case its a comma or period, not numeric.
If IsNumeric(strCost,IntFor,1) then
'it's numeric, get the letter. I use Cint
'below because your case statements are
'asking for an integer value, not a string
'value.
Select Case Cint(Mid(strCost,inFor,1))
Case 0
dtt = dtt & "X"
Case 1
dtt = dtt & "B"
Case 2
dtt = dtt & "R"
Case 3
dtt = dtt & "W"
Case 4
dtt = dtt & "H"
Case 5
dtt = dtt & "E"
Case 6
dtt = dtt & "K"
Case 7
dtt = dtt & "L"
Case 8
dtt = dtt & "G"
Case 9
dtt = dtt & "T" end select
End Function

Nov 13 '05 #2

P: n/a
Rolan wrote:
Need some assistance with regard to the following basic Function to
change digits to text, i.e., 295.78 = RTELG. Any suggestions or ideas
will be appreciated. Thanks.


If you have A2K or later try:

Private Sub Go_Click()
Dim i As Integer
Dim s As String
Dim curValue As Currency
Dim l(9) As String

l(0) = "X"
l(1) = "B"
l(2) = "R"
l(3) = "W"
l(4) = "H"
l(5) = "E"
l(6) = "K"
l(7) = "L"
l(8) = "G"
l(9) = "T"
curValue = CCur(295.78)
s = CStr(curValue * 100)
For i = 0 To 9
s = Replace(s, CStr(i), l(i))
Next i
MsgBox (s)
End Sub

Running this in A97 requires a Replace function replacement.
James A. Fortune

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.