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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Highlighting

Status
Not open for further replies.

DUF

Technical User
Mar 10, 2001
107
0
0
IE
In VB6 how do I HightLight text in a textbox when it recives focus. I want to Delete the text and enter new text

Can Anyone help??

Duf
 
There must be more to your question than I am reading. When a user drags the mouse over text in a textbox it is highlighted. If they then right click there is a default popmenu associated with the textbox that has cut, copy, paste, delete.
If you are giving the textbox focus programatically and not via the mouse, you can simply set its text to an empty string:

Private Sub Form_Load()
txtMyTextBox.Text = ""
End Sub
 
Here is the code to select entire text in a texbox when it receive focus...

Code:
Private Sub Text1_GotFocus ()
     Text1.SelStart = 0
     Text1.SelLength = Len(Text1.Text)
End Sub

Hope it Works :)
Bye
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top