Results 1 to 4 of 4

Thread: Selecting all text during GotFocus

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    43
    I want to select all the text in a textbox when it gets focus. Having touble finding that info.
    Tim

    VB6, SP4
    GT Vengeance

  2. #2
    Addicted Member
    Join Date
    May 2000
    Posts
    188
    txtField.SelStart = 0
    txtField.SelLength = Len(txtField.Text)

    Try this in your gotfocus event...

  3. #3
    Lively Member
    Join Date
    Jul 2000
    Location
    Vaxjo, Sweden
    Posts
    85
    Code:
    Public Sub gSelectText(txtText As TextBox)
    On Error Resume Next
      txtText.SelStart = 0
      txtText.SelLength = Len(txtText)
    End Sub
    on the GotFocus-event, call this procedure, like this:;

    Code:
    Private Sub Text1_GotFocus()
      Call gSelectText(Text1)
    End Sub
    Reality is what you make up when you can't handle your fantasies.

  4. #4

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    43

    Thumbs up

    Thank you both, works great! I knew there was something simple.
    Tim

    VB6, SP4
    GT Vengeance

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