PDA

View Full Version : Solved: Format Number in VBA



clhare
11-09-2006, 06:45 AM
I am working on a userform in Word and have been asked to set up a textbox to format the number entered without dollar sign and without decimal places--only thousand separator. Is there a way to do that?

:think: Thanks for your help!

clhare
11-09-2006, 08:09 AM
Turned out to be really simple. I put the following code behind the text box. If a "$" is entered, it'll just disappear when I start entering a number. Decimal points can't even be entered. Perfect!


txtAmount1.Value = Format(txtAmount1, "#,##0")

clhare
11-09-2006, 08:11 AM
Forgot to mention that I used the "Change" event. Doesn't work if I use the "Click" event.

lucas
11-09-2006, 08:16 AM
Glad you got this worked out. Thanks for posting your solution for others. Please mark your thread solved using the thread tools at the top of the page.