VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Enter to Tab

by K.Olayan (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (38 Votes)

This code gives the "enter" key the same functionality as the "tab" key in a vb form. When the user presses the "enter" key, it moves the focus to the next control, based on the tab index order. Don't forget to set the KeyPreview property of the form to True. (My thanks to Pennington. His TabToEnter2 code laid the foundation for this code.)

Assumes
The KeyPreview event of the form must be set to true for the Form_KeyPress event to fire.

Rate Enter to Tab

'add this to your form's code
Private Sub Form_KeyPress(KeyAscii As Integer)
 
 'catch both "Enter" keys on keyboard
 If (KeyAscii = vbKeyReturn) Or (KeyAscii = vbKeySeparator) Then
  SendKeys "{tab}"
 End If
End Sub

Download this snippet    Add to My Saved Code

Enter to Tab Comments

No comments have been posted about Enter to Tab. Why not be the first to post a comment about Enter to Tab.

Post your comment

Subject:
Message:
0/1000 characters