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

Highlight

Status
Not open for further replies.

jscorpion

Programmer
Nov 17, 2000
40
US
I am a new programmer and have written a few programs but I would like to know how to highlight a text field when tabing thru the program at runtime. As of now when you go from field to field you must delete previous information then type the new info. I would like the old info highlighted so when you start typing it replaces the old info. I can not seem to find it in the properties of the text box. Is it in there and not obvious or is it a line of code that must be put into the program. I would be much appriciative of any responses.

Thank you,

jscorpion
 
If you are using VBA in Office then change the AutoWordSelect property of the textbox to true. If that is not available, then you can insert this code into your form.
Code:
'The textboxes are set up in a control array
Private Sub Text1_GotFocus(Index As Integer)
    Call AutoSelect
End Sub

Public Sub AutoSelect()
    Dim c1 As Control
    Set c1 = Screen.ActiveForm.ActiveControl
    If TypeOf c1 Is TextBox Then
        c1.SelStart = 0
        c1.SelLength = Len(c1)
    End If
    Set c1 = Nothing
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top