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

format the text in the texbox

Status
Not open for further replies.

pingpang

Programmer
Feb 1, 2003
22
0
0
PH
How would you format the text(numeric) in a textbox?

Private Sub txtUprice_Change()
txtUprice.Text = Format(txtUprice.Text, "Php ###,###")
End sub

what i want is when the user starts typing the comma and would appear while the user inputs the amount.

thanks!
 

You might want to look at the maskedit box for the visual you are looking for.

Good Luck
 
Assuming 'Php' is your currency symbol, you can try.

Private Sub txtUprice_Change()
txtUprice.Text = Format(txtUprice.Text, "Php #,###,##0.00")
End sub
Thanks and Good Luck!

zemp
 
I have the following bit of code on the Keypress for a text box.

Text1.Text = Format(Text1.Text, "##,###,###,###.##")

This works to a certain extent, but when I'm typing in a large number, at various points the cursor moves to the start of the text box and the number doesn't appear in the ordered I typed it.

Any ideas how to fix this problem?
 
I would take it out of the Keypress event. Running the code every time an entry is made can cause problems.

Instead, place the code in the validate or lost focus event. Or use a mask edit box so the user can see a properly formatted entry as they are typing.

Thanks and Good Luck!

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top