Results 1 to 5 of 5

Thread: VB6 - Select All Text In Textbox

  1. #1

    Thread Starter
    Hyperactive Member Jonny1409's Avatar
    Join Date
    Mar 2005
    Posts
    308

    VB6 - Select All Text In Textbox

    I have approximately 75 text boxes on my form.

    Whenever one of these boxes get the focus I'd like it to select the whole field - basically so if there's a value already in there, you simply have to type over it rather than highlight the text in the box yourself.

    Obviously I can do this by putting code in the gotfocus event, but I don't want to have to do this 75 times.

    How can I get round this please?

    Thanks.

  2. #2
    Junior Member
    Join Date
    Oct 2008
    Posts
    24

    Re: VB6 - Select All Text In Textbox

    Could you make the textboxes into an array and have the clear textbox in the textbox_Click event? Just an idea.

  3. #3

    Thread Starter
    Hyperactive Member Jonny1409's Avatar
    Join Date
    Mar 2005
    Posts
    308

    Re: VB6 - Select All Text In Textbox

    I'm not sure - If I can I don't really know how to do that.

    However, what could complicate matters is the fact that 15 of the boxes relate to one thing, 15 relate to another etc

  4. #4
    Junior Member
    Join Date
    Oct 2008
    Posts
    24

    Re: VB6 - Select All Text In Textbox


  5. #5
    Frenzied Member
    Join Date
    Jan 2010
    Location
    Connecticut
    Posts
    1,687

    Re: VB6 - Select All Text In Textbox

    To select the contents:
    Code:
    Private Sub Text1_GotFocus()
    
       With Text1
          .SelStart = 0
          .SelLength = Len(.Text)
       End With
    
    End Sub
    VB6 Library

    If I helped you then please help me and rate my post!
    If you solved your problem, then please mark the post resolved

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