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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

automatic currency conversion 2

Status
Not open for further replies.

obulldog27

Programmer
Apr 26, 2004
169
US
The code below is set so if I enter an number such as: 40015 it will automatically be converted to $400.15 BUT the problem is if I enter 10 it will NOT convert to $10.00 but instead $.10 or the number 100 will convert to $1.00. I think if I can test to see if their are 2 or 3 digits then change to currency a different way. Can any one help?

If checkamtc.Text <> "" Then
checkamtc.Text = checkamtc.Text * 0.01
checkamtc.Text = Format(checkamtc.Text, "$#.00")
End If

The user will input just the number 10 (not 1000) so I need this to change when lost_focus to $10.00. but for $400.15 the user will enter 40015. The user will know he wants .15 as the cents. So the rule is the last two digits will always be cents.
 
And if the user wants to input $40015.00 ?

You need to clarify your question and the logic behind it - the coding is easy after that!

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
So the rule is the last two digits will always be cents.

That goes completely against what you said about wanting an entry of 10 to be $10.00 instead of $.10, or 100 to be $100.00 instead of $1.00.

I don't see any way to do this consistently and accurately.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
but if the user enters two digits 10 then add the .00 to the end but if the user enters 3 digits 100 by itself then add the .00

I guess I am confused as far as the many input options that can be entered and then how they are formatted.
 
Check out the Masked Edit Control (MSMASK32.OCX).

That should solve all your problems.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
I have used this code and seems to be working good.

If checkamtc.Text <> "" Then
If InStr(checkamtc.Text, ".") Then GoTo noconvert
If Len(checkamtc.Text) > 3 Then
temp = checkamtc.Text
checkamtc.Text = FormatCurrency(temp)
End If
noconvert:
checkamtc.Text = Format(checkamtc.Text, "$#.00")
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top