TextBox Formatting

T

ToddG

I am formatting the value of a textbox with the code:

TextBox113.Text = Format(TextBox113.Text, "#,##0.00")

This textbox is used to enter a price. I would like this
textbox to keep this format at all times - after a value
is entered AND when the userform is activated. Where would
I place this code and what declaration would be used?

TIA
 
B

Bob Phillips

Private Sub TextBox1_AfterUpdate()
TextBox113.Text = Format(TextBox113.Text, "#,##0.00")
End Sub

Private Sub UserForm_Activate()
TextBox113.Text = Format(TextBox113.Text, "#,##0.00")
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
T

ToddG

Thanks for your reply Bob

UserForm_Activate still isn't working. The next time the
userform is displayed it goes back to its standard format.

Also, there are quite a few textboxes in this userform in
various frames in a multipage. Is there a better way to
apply this format to all of them?
 
B

Bob Phillips

If you unload the form, all objects will re-initialise the next time you
show the form.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
T

ToddG

That worked, but only for one textbox. all the others stay
the same. anything i should do differently for multiple
textboxes?

Thanks a lot for your help.
 
B

Bob Phillips

Only add each one separately in the activate event and have separate
AfterUpdate events for each.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Top