Results 1 to 5 of 5

Thread: Auto Select Text

  1. #1

    Thread Starter
    Addicted Member slashandburn's Avatar
    Join Date
    Aug 1999
    Location
    Marietta, Ga
    Posts
    229

    Question Auto Select Text

    How could i auto select all the text in a textbox? Like when i click
    in the box it would select all text.

  2. #2
    Member
    Join Date
    Jul 2002
    Location
    china(ÖØÇì)
    Posts
    60

    Re: Auto Select Text

    text1.seltext=text1
    I am a vb fine,
    but my English was poor.

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. Private Sub Text1_GotFocus()
    2. Text1.SelStart = 0
    3. Text1.SelLength = Len(Text1.Text)
    4. End Sub

  4. #4

    Thread Starter
    Addicted Member slashandburn's Avatar
    Join Date
    Aug 1999
    Location
    Marietta, Ga
    Posts
    229
    Thanks, Now it will be so much easier to edit all 16 text boxes.

  5. #5
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    Originally posted by Hack
    VB Code:
    1. Private Sub Text1_GotFocus()
    2. Text1.SelStart = 0
    3. Text1.SelLength = Len(Text1.Text)
    4. End Sub
    to make things easier:
    VB Code:
    1. 'In a module
    2. Public Sub HighlightText(objControl As TextBox)
    3.   With objControl
    4.     .SelStart = 0
    5.     .SelLength = Len(.Text)
    6.   End With
    7. End Sub
    8.  
    9. 'In your form
    10. Private Sub Text1_GotFocus()
    11.   HighlightText Text1
    12. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width