473,414 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Assistance with Digits To Text Function

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
2 1354
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Westcoast Sheri | last post by:
What is the most efficient way of extracting the first two digits in a string? The following is wrong for me, because it only gives me the first instance of two digits together: $string =...
3
by: msnews.microsoft.com | last post by:
Hey Guys, I was wondering if any of you could help me out with converting a single digit (ie: 1, 2, 3, etc) to double digits (ie: 01, 02, 03, etc). I am trying to convert the date in...
7
by: Tod Thames | last post by:
I am running SQL Server 7.0 and using a web interface. I would like for a user to be able to input multiple values into a single field with some sort of delimiter (such as a comma). I want to...
13
by: CHRISTOF WARLICH | last post by:
Hi, does anyone know of an efficient way to find the number of digits (i.e. the most significant position that is 1) of a binary number? What I found so far is: - digits = (int) log2(number),...
0
by: Rolan | last post by:
I'm using Access 97 and need some assistance in sorting out a proper DSum expression, or maybe even DCount might be an alternative. I have tried numerous combinations, but with no apparent success....
4
by: italia | last post by:
I changed the Fieldsize Property from text to Long Integer and Decimal Places = 6. I had decimals in the original field. But after the transfer, the digits after the decimals are gone. Now...
27
by: Luke Wu | last post by:
Is there a C function that returns the number of digits in an input int/long? example: numdigits(123) returns 3 numdigits(1232132) returns 7
18
by: Kuljit | last post by:
I am doing Engineering(B.Tech) in Computer Science. I have a question for which i am struggling to write a C code(program). It struck me when we were being taught about a program which counts the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.