![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Professional Programmer
|
Key commands
I've been doing a lot of visual basic programs in school which require me to type in some text, then click the command button. Over and over. It's really annoying, and I was wondering, how do I make it so that my command1 button responds to both clicking and hitting my enter key?
|
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Apr 2005
Posts: 218
Rep Power: 4
![]() |
Hitting the enter key does the same as pressing the command button, of course the command button must be selected in order for it to work, but there is only one command button on your form..hitting the enter button should do the same function as pressing the button.
I could be wrong but I tried and tested this just now and it worked perfectly. Oh and are you using visual basic 6 or visual basic 2005, not that it should matter but it might. |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Mar 2006
Location: Tennessee
Posts: 41
Rep Power: 0
![]() |
I believe the object has to have the focus unless the key_down function has been coded specifically to activate the object in question. If somebody clicks on a text box, persay, then the text box has the focus and the enter key will only add a new line, provided the text box has multiline enabled.
Feel free to correct me if I'm wrong. Edit: I just added 3 text boxes to a form, then added a button. By default, the first text box has focus and enter does nothing but calls system error beep. I had to tab the focus to the button for the enter key to work. I used a standard exe project, with a blank form. Last edited by PPoA; Mar 13th, 2006 at 9:29 AM. |
|
|
|
|
|
#4 |
|
Professional Programmer
|
Visual Basic 6
|
|
|
|
|
|
#5 | |
|
Programmer
Join Date: Mar 2006
Location: Tennessee
Posts: 41
Rep Power: 0
![]() |
Quote:
|
|
|
|
|
|
|
#6 |
|
Professional Programmer
|
I have read this, and what I am asking for is the key_down command to do this. I have no idea how it works and need some help. I need this ASAP.
|
|
|
|
|
|
#7 |
|
Programmer
Join Date: Mar 2006
Location: Tennessee
Posts: 41
Rep Power: 0
![]() |
Once you add an object to the form, such as the button, you can go to the code page (page where you enter your code) and choose your button from the drop down list on the left, then choose the keydown function from the drop down list on the right to automatically add the header for the keydown for that specific button. If you need more help, just highlight the word keydown and press F1 while in VB. This opens Microsoft's help file with the keyword automatically queried.
|
|
|
|
|
|
#8 |
|
Professional Programmer
|
Our retarded school decided not to give us the bloody help file. Sorry, can you tell me.
|
|
|
|
|
|
#9 |
|
PFO Founder
![]() ![]() |
If you mostly just hit one command button then there is a property that you can set in one of the buttons, The property is called Default just set that to true, and when ever you hit the enter key on your form then that button will be used. But this is only good for one command button
__________________
BIG K aka Kyle Programming Forums Kyle K Online Please do not PM or email me programming questions. Post them in the forums instead. |
|
|
|
|
|
#10 |
|
Professional Programmer
|
thanks, big k
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|