Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default How to force selection of all current text in textbox control onentry?

Hi All

I have a text box on a form. When the user selects the text box it is
*always* to completely change the value. Therefore I would like to
program an event that selects all the current text in the text box
when the user selects it - that way they are ready immediately to
begin typing the new value.

Hoever I cannot get this to work:

Private Sub txtCanvasSizeWidth_Enter()
Me.txtCanvasSizeWidth.SelStart = 0
Me.txtCanvasSizeWidth.SelLength = Len(Me.txtCanvasSizeWidth)
End Sub

Can anyone help? Thanks in advance for any ideas?

Chrisso
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default How to force selection of all current text in textbox control on e

Try putting it in the initialize evert. I used this code and it worked.

Private Sub UserForm_Initialize()
TextBox1.MultiLine = True
TextBox1.EnterFieldBehavior = _
fmEnterFieldBehaviorRecallSelection
TextBox1.Text = "Type your text here. " _
& "Use CTRL+ENTER to start a new line."
Me.TextBox1.SelStart = 0
Me.TextBox1.SelLength = Len(Me.TextBox1)
End Sub

"Chrisso" wrote:

Hi All

I have a text box on a form. When the user selects the text box it is
*always* to completely change the value. Therefore I would like to
program an event that selects all the current text in the text box
when the user selects it - that way they are ready immediately to
begin typing the new value.

Hoever I cannot get this to work:

Private Sub txtCanvasSizeWidth_Enter()
Me.txtCanvasSizeWidth.SelStart = 0
Me.txtCanvasSizeWidth.SelLength = Len(Me.txtCanvasSizeWidth)
End Sub

Can anyone help? Thanks in advance for any ideas?

Chrisso

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default How to force selection of all current text in textbox control on entry?

If your user Tabs into the TextBox, it will automatically select all the
text without you having to do anything; so I presume you are talking about
selecting the TextBox using the mouse. If so, try putting the code you
posted into the MouseDown event for the TextBox and see if that is the
effect you are after. (You could put it in the MouseUp event, and logic
would almost dictate that to be the correct event to use; however, the
selection method is more instantaneous using the MouseDown event.)

Rick


"Chrisso" wrote in message
...
Hi All

I have a text box on a form. When the user selects the text box it is
*always* to completely change the value. Therefore I would like to
program an event that selects all the current text in the text box
when the user selects it - that way they are ready immediately to
begin typing the new value.

Hoever I cannot get this to work:

Private Sub txtCanvasSizeWidth_Enter()
Me.txtCanvasSizeWidth.SelStart = 0
Me.txtCanvasSizeWidth.SelLength = Len(Me.txtCanvasSizeWidth)
End Sub

Can anyone help? Thanks in advance for any ideas?

Chrisso


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
Force save to CURRENT directory CLR Excel Programming 5 October 26th 07 03:10 PM
Getting paragraphs of text into a textbox control Gordon[_2_] Excel Programming 5 August 19th 05 08:47 AM
Legnth of text in textbox control rgarber50 Excel Discussion (Misc queries) 3 July 15th 05 02:18 PM
How to force current directory CLR Excel Programming 8 November 30th 04 01:11 AM
How to move cursor from one textbox control to another textbox con Tom Ogilvy Excel Programming 1 September 16th 04 03:42 PM


All times are GMT +1. The time now is 07:35 PM.

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

About Us

"It's about Microsoft Excel"