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

Problems with Converting Text to Currency

P: n/a
I would appreciate anyone's assistance to sort out what change in code
is needed for 'TextToDigits()' as shown below. The function does
convert the text to numbers, but it is two decimals off, i.e., 26500
($265.00) is converted to $26,500.00. Thanks for your time.

Rolan
Function XlateDigit(ByVal C As String) As String
C = UCase(C)
Select Case C
Case "X"
XlateDigit = 0
Case "C"
XlateDigit = 1
Case "R"
XlateDigit = 2
Case "W"
XlateDigit = 3
Case "H"
XlateDigit = 4
Case "E"
XlateDigit = 5
Case "K"
XlateDigit = 6
Case "L"
XlateDigit = 7
Case "G"
XlateDigit = 8
Case "T"
XlateDigit = 9
Case Else
XlateDigit = 0
End Select
End Function

Function TextToDigits(ByVal Cost As Variant) As Variant

Dim I As Currency

If VarType(Cost) = 8 Then
For I = 1 To Len(Cost)
Mid(Cost, I, 1) = XlateDigit(Mid(Cost, I, 1))
Next I
End If

TextToDigits = Cost

End Function

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


P: n/a
Rog
What a strange function...
If you're sure the input always contains cents you could change the
last line to TextToDigits = Cost / 100

Nov 13 '05 #2

P: n/a
"Rolan" <co******@safe-mail.net> wrote in
news:11**********************@z14g2000cwz.googlegr oups.com:
I would appreciate anyone's assistance to sort out what change
in code is needed for 'TextToDigits()' as shown below. The
function does convert the text to numbers, but it is two
decimals off, i.e., 26500 ($265.00) is converted to
$26,500.00. Thanks for your time.

Rolan


Purely as an excercise in cryptography, try

TextToDigits = Cost/100
--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.