Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

highlight text box using a tab key

Status
Not open for further replies.

jason12776

Technical User
Nov 15, 2001
93
US
How can I highlight the text in a text box on the next tabStop using the tab key? I'm tried so many different combinations of solutions and nothing seems to work. I can get it to work for any other key I want, but not the tab key. Any ideas?

Cheers.
 
Try this:
Code:
Private Sub Text2_GotFocus()
Text2.SelStart = 0
Text2.SelLength = Len(Text2.Text)
End Sub
When you tab to Text2 the whole text will be highlighted Let me know if this helps
________________________________________________________________
If you are worried about how to post, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
To clarify: I want the text within the text box to be highlighted. Sorry.
 
I'm missing something here. Code posted does highlight all text in Text2 (when run on my machine)
Have I misunderstood the question? Let me know if this helps
________________________________________________________________
If you are worried about how to post, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
First, start by creating a control array and then put this in the GotFocus event the the control array of textboxes:


Private Sub FieldBoxes_GotFocus(Index As Integer)
FieldBoxes(Index).SelStart = 0
FieldBoxes(Index).SelLength = Len(FieldBoxes(Index))
End Sub Swi
 
Maybe you have misunderstood the question. I wanted to be able to tab through a series of text boxes, and when the focus was on a specific text box, highlight the text within the text box. It works just the way I need it to. Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top