What is the best way to select all the text and highlight it in a text box, when i give it focus? Any help would be great
[Edited by dionj on 05-19-2000 at 11:29 AM]
Printable View
What is the best way to select all the text and highlight it in a text box, when i give it focus? Any help would be great
[Edited by dionj on 05-19-2000 at 11:29 AM]
Check it out
ALL THE BESTCode:Private Sub Text1_GotFocus()
Text1.SelLength = Len(Text1.Text)
End Sub
I suggest that you use a richtextbox control, in order for you to use it though you must go to projects --> components, then click Microsoft Rich Text Box control.
Then you can add it to the form just like a text box. But it gives you some nice methods to use, Ill let you look them up of course though. If you still need help after this, email me or repost.
Cheers
Bill Rogers
Actually i think you will find that you need to specify where to start the selection at. Otherwise you might get half of the text selected or none if the cursor is at the end of the box.
Code:Private Sub txtName_GotFocus()
txtName.SelStart = 0
txtName.SelLength = Len(txtName.Text)
End Sub