how to use key press event in Visual Basic 6

5 pts.
Tags:
VB
Visual Basic
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

Answer Wiki

Thanks. We'll let you know when a new response is added.

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.

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Kccrosser
    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 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following