Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

In VB6 program simulate "Tab"by pressing the enter key 3

Status
Not open for further replies.

tyedyejenn

Programmer
Jun 14, 2000
35
US
I wrote a data entry program using VB6. I was under the impression users would use the Tab key to navigate through fields(I set up the tab indexes and such). Well the bosses would also like the option of using the enter key to navigate through fields(they want the user to be able to use either tab or enter to advance through fields) I thought maybe this could be done in the keypress event by checking the ascii value of the key pressed, but this was causing major extra work. I was hoping there was an easier solution. Any suggestions are greatly appreciated. Thanks in advance for the help
Jenn
 
Try this. Put this event handler in code pane for your form. Note that you should set the KeyPreview property of the form to True.


Private Sub Form_KeyPress(KeyAscii As Integer)
If TypeName(Me.ActiveControl) = "TextBox" Then
If KeyAscii = 13 Then
KeyAscii = 0
SendKeys "{Tab}"
End If
End If
End Sub
 
Thanks mohmehran

that worked great. I totally appreciate the quick response. Have a great day
Jenn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top