Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Help with Textbox formatting

I have several textboxes in userforms which either need to be currency or %. I have tried the following code but it only formats correctly when a change is made. Once the form is closed and reopened the formatting is gone. I hope someone can help

Sub TextBox1_OnChang
TextBox1.Value = Format(TextBox1.Value, "$#,##0"
End Su

In advance thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Help with Textbox formatting

Put your formatting in the UserForm_Initialize() event eg

Sub UserForm_Initialize()
TextBox1.Value = Format(TextBox1.Value, "$#,##0")
End Sub

Cheers
Nigel

"bruce forster" wrote in message
...
I have several textboxes in userforms which either need to be currency or

%. I have tried the following code but it only formats correctly when a
change is made. Once the form is closed and reopened the formatting is
gone. I hope someone can help.

Sub TextBox1_OnChange
TextBox1.Value = Format(TextBox1.Value, "$#,##0")
End Sub

In advance thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Help with Textbox formatting

What's this OnChange event?

--

HTH

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

"bruce forster" wrote in message
...
I have several textboxes in userforms which either need to be currency or

%. I have tried the following code but it only formats correctly when a
change is made. Once the form is closed and reopened the formatting is
gone. I hope someone can help.

Sub TextBox1_OnChange
TextBox1.Value = Format(TextBox1.Value, "$#,##0")
End Sub

In advance thanks.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Help with Textbox formatting

OnChange seems to fire the formatting once the textbox is changed
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Help with Textbox formatting

For activeX controls, to the best of my knowledge,
There is no onchange event. There is a change event and a click event.

--
Regards,
Tom Ogilvy

"bruce forster" wrote in message
...
OnChange seems to fire the formatting once the textbox is changed





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Help with Textbox formatting

Okay. But when I used a _Change code the formatting works but then when I close the userform and reinitialize it goes away. what should I do??
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Help with Textbox formatting

Did you try Nigel's suggestion?

--

HTH

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

"bruce forster" wrote in message
...
Okay. But when I used a _Change code the formatting works but then when I

close the userform and reinitialize it goes away. what should I do??


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help with Textbox formatting

A textbox is always plain text. Try putting that line in the initialize
event of the form.


---
Message posted from http://www.ExcelForum.com/

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
formatting a textbox Ed Excel Discussion (Misc queries) 1 February 24th 08 09:15 PM
Textbox Formatting jmc8355 Excel Discussion (Misc queries) 3 April 24th 07 06:30 PM
textbox formatting jnf40 Excel Discussion (Misc queries) 1 August 3rd 06 08:12 PM
TextBox Formatting grahammal Excel Discussion (Misc queries) 3 April 12th 06 04:54 PM
TextBox Formatting ToddG[_2_] Excel Programming 5 April 7th 04 09:29 PM


All times are GMT +1. The time now is 05:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"