[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 672
  • Last Modified:

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

0
StevenLogic
Asked:
StevenLogic
  • 2
1 Solution
 
GrahamSkanCommented:
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
 
GrahamSkanCommented:
0
 
Éric MoreauSenior .Net ConsultantCommented:
Yes it is working but you have to set the form's KeyPreview property to True
0
 
StevenLogicAuthor Commented:
Great.  Thanks.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now