Results 1 to 4 of 4

Thread: Need help with text boxes

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    4

    Question

    What is the best way to select all the text and highlight it in a text box, when i give it focus? Any help would be great

    [Edited by dionj on 05-19-2000 at 11:29 AM]
    j Dion

  2. #2

    Thumbs up

    Check it out

    Code:
    Private Sub Text1_GotFocus()
       Text1.SelLength = Len(Text1.Text)
    End Sub
    ALL THE BEST
    Madhusudana Gorthi [email protected]
    Senior Software Engineer
    www.stgil.com

  3. #3
    Hyperactive Member
    Join Date
    May 2000
    Posts
    367
    I suggest that you use a richtextbox control, in order for you to use it though you must go to projects --> components, then click Microsoft Rich Text Box control.

    Then you can add it to the form just like a text box. But it gives you some nice methods to use, Ill let you look them up of course though. If you still need help after this, email me or repost.

    Cheers
    Bill Rogers

  4. #4
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Actually i think you will find that you need to specify where to start the selection at. Otherwise you might get half of the text selected or none if the cursor is at the end of the box.

    Code:
    Private Sub txtName_GotFocus()
        txtName.SelStart = 0
        txtName.SelLength = Len(txtName.Text)
    End Sub
    Iain, thats with an i by the way!

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