Results 1 to 3 of 3

Thread: Highlighting text box text [SOLVED]

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member boku's Avatar
    Join Date
    Dec 2004
    Posts
    386

    Resolved Highlighting text box text [SOLVED]

    I have a bit of coding like this:

    VB Code:
    1. Private Sub txtUser_KeyDown(KeyCode As Integer, Shift As Integer)
    2.  
    3. txtUser.SelStart = 0
    4. txtUser.SelLength = Len(txtUser.Text)
    5.  
    6. If KeyCode = vbKeyReturn Then
    7. txtPass.SetFocus
    8. End If
    9.  
    10. End Sub

    but as you probably could guess im trying to select the text when i tab to it but i also want to be able to jump out again with the enter button

    ---

    this will work for the highlighting of the text, but then i cant press return to jump out again

    VB Code:
    1. Private Sub txtUser_[B]GotFocus[/B]()
    2.  
    3. txtUser.SelStart = 0
    4. txtUser.SelLength = Len(txtUser.Text)
    5.  
    6. If KeyCode = vbKeyReturn Then
    7. txtPass.SetFocus
    8. End If
    9.  
    10. End Sub

    ---

    and this will work for the jumping out but not selecting the text

    VB Code:
    1. Private Sub txtUser_[B]KeyDown(KeyCode As Integer, Shift As Integer)[/B]
    2.  
    3. txtUser.SelStart = 0
    4. txtUser.SelLength = Len(txtUser.Text)
    5.  
    6. If KeyCode = vbKeyReturn Then
    7. txtPass.SetFocus
    8. End If
    9.  
    10. End Sub

    ---

    Does any body know of a solution?

    I tried this aswel lol

    VB Code:
    1. Private Sub txtUser_[B]KeyDown_GotFocus(KeyCode As Integer, Shift As Integer)[/B]
    2.  
    3. txtUser.SelStart = 0
    4. txtUser.SelLength = Len(txtUser.Text)
    5.  
    6. If KeyCode = vbKeyReturn Then
    7. txtPass.SetFocus
    8. End If
    9.  
    10. End Sub
    Last edited by boku; Feb 10th, 2005 at 08:29 PM.
    -BoKu-

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