Results 1 to 5 of 5

Thread: Need some hep - very easy

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Australia
    Posts
    149
    Just wanted to know how to select the text in a text box when that text box get the focus.

    Thanks

    Hurgh

  2. #2
    Guest
    Try this:

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

  3. #3
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    Matthew - Shouldn't the last line ("Text1.SetFocus") be omitted? Otherwise, won't the GotFocus event will execute in an endless loop?
    "It's cold gin time again ..."

    Check out my website here.

  4. #4
    Fanatic Member Dim's Avatar
    Join Date
    Jul 2000
    Posts
    620
    Code:
    Private Sub Text2_GotFocus()
        Text2.SelStart = 0
        Text2.SelLength = Len(Text2.Text)
    End Sub
    Dim

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Originally posted by BruceG
    Matthew - Shouldn't the last line ("Text1.SetFocus") be omitted? Otherwise, won't the GotFocus event will execute in an endless loop?
    It shoul be omitted. But it wont get in to an endless loop because the object allready has the focus so even if you call SetFocus the GotFocus event wont be fired.

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