Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Long Beach, California, USA
    Posts
    233
    Thanks
    0
    Thanked 0 Times in 0 Posts

    textbox sellength (xl2000)

    I am ready to leap...I could swear that I have done this before but for the life of me I can not make this work.

    On userform the user can enter a name to be removed from a list. User enters a last name and clicks button. Routine searchs for name, if not found presents an error message and exits sub. I want the entered text to be highlighted but I can not make it happen.

    <pre> sNoGoMsg = "The entry " & frmAddRemove.txtLast & " could not be found." & vbCrLf
    sNoGoMsg = sNoGoMsg & "Please verify spelling of last name."
    MsgBox sNoGoMsg, vbExclamation, "Invalid Entry"
    With frmAddRemove.txtLast
    .SelLength = Len(frmAddRemove.txtLast.Text)
    End With
    Exit Sub
    </pre>


    I have played with seltext, selstart, set focus plus various combinations of them all. There are other textboxs on the form but they are disabled for a remove action. The EnterFieldBehaviorSelectAll does what is desired but we never LEAVE the textbox. Is the answer staring me in the face?

    <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15>

  2. #2
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Long Beach, California, USA
    Posts
    233
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: textbox sellength (xl2000)

    <img src=/S/bingo.gif border=0 alt=bingo width=15 height=22>

    ...never mind. sheeezzzzz

    <pre> With TextBox2
    .SetFocus
    .SelStart = 0
    .SelLength = Len(TextBox2.Text)
    End With
    </pre>


  3. #3
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: textbox sellength (xl2000)

    The text box must have the focus for the text to be selected. The following should work:

    <pre> With frmAddRemove.txtLast
    .SetFocus
    .SelStart = 0
    .SelLength = Len(.Text)
    End With
    </pre>

    Legare Coleman

  4. #4
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Long Beach, California, USA
    Posts
    233
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: textbox sellength (xl2000)

    I hang my head in shame...what a dufus.

    Thank you for your response Legare.

Posting Permissions

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