English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

How do I code a button so that when a user presses the enter button, the button is clicked? That is to say, that on my form, I have a user name and password text box, along with a login button. I want to be able to hit the enter key, and trigger the events in my button class. Thanks so much in advance!

2007-01-22 12:57:41 · 2 answers · asked by nohscompclub3 1 in Computers & Internet Programming & Design

2 answers

In Visual BASIC 6, there is a property on the property sheet for a command button called "DEFAULT". It is a boolean variable. If it is set to TRUE, then the ENTER key on the keyboard will activate the command button.

Another property that might interest you is the CANCEL property of the command button - this property allows the user to "click" the button by pressing the "escape" key on the keyboard.

2007-01-22 13:29:06 · answer #1 · answered by Richard H 7 · 0 0

Go to the form load method on whatever form the button is that you want to accept the enter key. Type me.acceptbutton = whatever

Replace "whatever" with the name of the button that you want to accept the enter key.

Hope this helps!

2007-01-22 21:18:20 · answer #2 · answered by Mikecool509 3 · 0 0

fedest.com, questions and answers