Select all text when selecting a text box? 
Author Message
 Select all text when selecting a text box?

Hello,

Can someone please tell me what I need to do to select (highlight) all the
text in a text box when it has the focus so the user can just type in their
bit.

sorta like

Sub txtWhatEver_GotFocus
   txtWhatEver.MagicallySelected = True
end Sub

I'm sure it must be real simple, but the last hour of fiddling hasn't
helped.

Ta

David



Mon, 20 Nov 2000 03:00:00 GMT  
 Select all text when selecting a text box?

The code below is what I use for this. Note that this code assumes an array
of text boxes on the form.

Hope it helps

Joseph Scally

Private Sub Text1_GotFocus(Index As Integer)
Text1(Index).SelStart = 0
Text1(Index).SelLength = Len(Text1(Index).Text)
End Sub

Quote:

>Hello,

>Can someone please tell me what I need to do to select (highlight) all the
>text in a text box when it has the focus so the user can just type in their
>bit.

>sorta like

>Sub txtWhatEver_GotFocus
>   txtWhatEver.MagicallySelected = True
>end Sub

>I'm sure it must be real simple, but the last hour of fiddling hasn't
>helped.

>Ta

>David



Mon, 20 Nov 2000 03:00:00 GMT  
 Select all text when selecting a text box?

Hi,

Here ya go. Add the following to your form:

Private Sub SelectMe(This As TextBox)

This.SelStart = 0
This.SelLength = Len(This.Text)
End Sub

Next, add the following code to your text box:

Private Sub txYourText_GotFocus()
Call SelectMe(Me.ActiveControl)
End Sub

Enjoy!
That Dude

Quote:

>Hello,

>Can someone please tell me what I need to do to select (highlight) all the
>text in a text box when it has the focus so the user can just type in their
>bit.

>sorta like

>Sub txtWhatEver_GotFocus
>   txtWhatEver.MagicallySelected = True
>end Sub

>I'm sure it must be real simple, but the last hour of fiddling hasn't
>helped.

>Ta

>David



Mon, 20 Nov 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Selecting text in a text box

2. Selecting text in disabled text boxes...

3. Rich Text Box and Selected Text

4. Selecting Text in a Rich Text box

5. Setting properties on selected text in a text box

6. Selected Text in Text Box

7. Auto select text in a text box

8. Selecting Text in a text box

9. Rich text box - selected text

10. Text box cursor position when text is selected

11. how can i change the backcolor of a selected text in a rich text box

12. Selecting all the text in a Text Box

 

 
Powered by phpBB® Forum Software