Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 13th, 2006, 9:05 AM   #1
Indigno
Professional Programmer
 
Indigno's Avatar
 
Join Date: Dec 2005
Location: Anywhere non-productive
Posts: 267
Rep Power: 0 Indigno is an unknown quantity at this point
Send a message via AIM to Indigno Send a message via MSN to Indigno Send a message via Yahoo to Indigno
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?
Indigno is offline   Reply With Quote
Old Mar 13th, 2006, 9:11 AM   #2
zorin
Hobbyist Programmer
 
Join Date: Apr 2005
Posts: 218
Rep Power: 4 zorin is on a distinguished road
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.
zorin is offline   Reply With Quote
Old Mar 13th, 2006, 9:17 AM   #3
PPoA
Programmer
 
PPoA's Avatar
 
Join Date: Mar 2006
Location: Tennessee
Posts: 41
Rep Power: 0 PPoA is on a distinguished road
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.
PPoA is offline   Reply With Quote
Old Mar 13th, 2006, 9:18 AM   #4
Indigno
Professional Programmer
 
Indigno's Avatar
 
Join Date: Dec 2005
Location: Anywhere non-productive
Posts: 267
Rep Power: 0 Indigno is an unknown quantity at this point
Send a message via AIM to Indigno Send a message via MSN to Indigno Send a message via Yahoo to Indigno
Visual Basic 6
Indigno is offline   Reply With Quote
Old Mar 13th, 2006, 9:32 AM   #5
PPoA
Programmer
 
PPoA's Avatar
 
Join Date: Mar 2006
Location: Tennessee
Posts: 41
Rep Power: 0 PPoA is on a distinguished road
Quote:
Originally Posted by Indigno
Visual Basic 6
Same here.
PPoA is offline   Reply With Quote
Old Mar 13th, 2006, 9:34 AM   #6
Indigno
Professional Programmer
 
Indigno's Avatar
 
Join Date: Dec 2005
Location: Anywhere non-productive
Posts: 267
Rep Power: 0 Indigno is an unknown quantity at this point
Send a message via AIM to Indigno Send a message via MSN to Indigno Send a message via Yahoo to Indigno
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.
Indigno is offline   Reply With Quote
Old Mar 13th, 2006, 9:46 AM   #7
PPoA
Programmer
 
PPoA's Avatar
 
Join Date: Mar 2006
Location: Tennessee
Posts: 41
Rep Power: 0 PPoA is on a distinguished road
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.
PPoA is offline   Reply With Quote
Old Mar 13th, 2006, 9:49 AM   #8
Indigno
Professional Programmer
 
Indigno's Avatar
 
Join Date: Dec 2005
Location: Anywhere non-productive
Posts: 267
Rep Power: 0 Indigno is an unknown quantity at this point
Send a message via AIM to Indigno Send a message via MSN to Indigno Send a message via Yahoo to Indigno
Our retarded school decided not to give us the bloody help file. Sorry, can you tell me.
Indigno is offline   Reply With Quote
Old Mar 13th, 2006, 11:19 AM   #9
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,623
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
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.
big_k105 is offline   Reply With Quote
Old Mar 14th, 2006, 7:20 PM   #10
Indigno
Professional Programmer
 
Indigno's Avatar
 
Join Date: Dec 2005
Location: Anywhere non-productive
Posts: 267
Rep Power: 0 Indigno is an unknown quantity at this point
Send a message via AIM to Indigno Send a message via MSN to Indigno Send a message via Yahoo to Indigno
thanks, big k
Indigno is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:47 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC