Is there a form KeyPreview event in VB6?

Hi,

I'd like to capture keys being pressed before they go into a controll (ie. text box, grid, etc.)

Example code that doesn't work is as follows:

Create a new project, a new form, and place a text control with default name 'Text1'

place this code in the form:
Private Sub Form_KeyPress(KeyAscii As Integer)
   MsgBox Chr$(KeyAscii)
End Sub

StevenLogicAsked:
Who is Participating?
 
Éric MoreauSenior .Net ConsultantCommented:
Yes it is working but you have to set the form's KeyPreview property to True
0
 
GrahamSkanRetiredCommented:
No, The Form _KeyPress event is only possible if the Form itself has the focus. If there any controls on the form that can receive the focus, then the form cannot be in focus.
0
 
GrahamSkanRetiredCommented:
0
 
StevenLogicAuthor Commented:
Great.  Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.