devxlogo

Code All KeyPress Events in One Move

Code All KeyPress Events in One Move

Do you need to tab through all those edit boxes? Are you tired of coding all of their KeyPress events? If so, set the tab indexes as you normally would. Then set the form key preview to True. In the form KeyPress event, enter this code:

 If KeyAscii = 13 Then	SendKeys "{Tab}"	KeyAscii = 0End If

This will tab to all the controls, so if you don’t want to tab to a command button, set its tab stop to False.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist