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

Currency Input In Textbox

Status
Not open for further replies.

Adalius

Programmer
Feb 11, 2011
2
US
Does anybody have an elegant solution to the problem below? I can piecemeal to get the desired solution but it looks like garbage to me, granted I have the flu right now and the cough syrup is making my brain run like mush.

Basically I have a textbox that the user enters a dollar amount in. I want it to function just like a credit card punch terminal or hundreds of other monetary input devices, which is to act like this.

Display: $0.00
<user hits 5>
Display: $0.05
<user hits 6>
Display: $0.56
<user hits 7>
Display: $5.67
So on and so forth, adding commas as needed as it scales up. So basically as you type it automatically right justifies the number in the format field. I've tried messing with input masks and can't get them to work right for this as the mask always starts at the left-most position. Setting formatting to currency works the same way, typing 55 gets you $55 not $0.55.

Thoughts? Ideas? Simple setting for the textbox that I overlooked in my sickly state?
 
If you really want it to work that way after each key press yoo have to play games with the On key events... I think the on key down was the one that is forgiving the one time I had to use them.

Alternately on the before update check you might consider dividing the value by 100... I am thinking the left most position of the textvalue property of the control will be $ if someone is already entering currency.
 
Using KeyDown is the cludgy way I had it done before but, again, cludgy. Was really hoping there was something easy like a way to right justify the input mask since ! doesn't work with data entry only with formatting existing fields.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top