TextBox Formatting

  • Thread starter Thread starter ToddG
  • Start date Start date
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
 
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)
 
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?
 
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)
 
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.
 
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top