5 pts.
 how to use key press event in Visual Basic 6
Hellow sir, i want to know about the key press event to toggle throught text boxes , combo boxes ,list boxes etc.plz tell me all about the key press event details and simple code to execute it .

Software/Hardware used:
i am using the vb 6
ASKED: January 27, 2010  7:32 AM
UPDATED: October 17, 2011  1:27 PM

Answer Wiki:
You could use the KeyPress, KeyDown, KeyUp events. If you are going to manage these events at the form level, you might want to set the KeyPreview property of the form to 'true'. Example: <pre>Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = 37 Then MsgBox ("The left arrow was pressed") End If End Sub</pre> Please provide more details if you need further help.
Last Wiki Answer Submitted:  January 27, 2010  2:58 pm  by  carlosdl   63,535 pts.
All Answer Wiki Contributors:  carlosdl   63,535 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

I would avoid the KeyPress or KeyDown events unless you really understand what these mean and have a specific need to process these events. When you play with the KeyPress/KeyDown events, you need to worry about the states of multiple keys (shift, alt, fn) and it is real easy to get wrapped around the axle with recursive event entries.

It is MUCH safer to handle Change events, or if you must deal with key events, I would suggest using the KeyUp event, which will only occur once per key press. By waiting until the user releases the keys, the event handling is much simplified.

 3,830 pts.