Highlighting text box text [SOLVED]
I have a bit of coding like this:
VB Code:
Private Sub txtUser_KeyDown(KeyCode As Integer, Shift As Integer)
txtUser.SelStart = 0
txtUser.SelLength = Len(txtUser.Text)
If KeyCode = vbKeyReturn Then
txtPass.SetFocus
End If
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:
Private Sub txtUser_[B]GotFocus[/B]()
txtUser.SelStart = 0
txtUser.SelLength = Len(txtUser.Text)
If KeyCode = vbKeyReturn Then
txtPass.SetFocus
End If
End Sub
---
and this will work for the jumping out but not selecting the text
VB Code:
Private Sub txtUser_[B]KeyDown(KeyCode As Integer, Shift As Integer)[/B]
txtUser.SelStart = 0
txtUser.SelLength = Len(txtUser.Text)
If KeyCode = vbKeyReturn Then
txtPass.SetFocus
End If
End Sub
---
Does any body know of a solution?
I tried this aswel :rolleyes: lol
VB Code:
Private Sub txtUser_[B]KeyDown_GotFocus(KeyCode As Integer, Shift As Integer)[/B]
txtUser.SelStart = 0
txtUser.SelLength = Len(txtUser.Text)
If KeyCode = vbKeyReturn Then
txtPass.SetFocus
End If
End Sub
Re: Highlighting text box text
Did you try a combination of the two events? You do know you can have more than one event per control.
VB Code:
Private Sub txtUser_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
txtPass.SetFocus
End If
End Sub
Private Sub txtUser_GotFocus()
txtUser.SelStart = 0
txtUser.SelLength = Len(txtUser.Text)
End Sub
Re: Highlighting text box text
Thanks a lot :)
No i didnt know that :rolleyes: