Solved

Keydown Question.

Posted on 1998-11-18
3
167 Views
Last Modified: 2010-05-03
I'm using the learning edition of Visual Basic 6 that came with a book but it has no online help.

I need to know how to recognise a key press and assisgn a sub to it.

I.E someone presses 'Enter', something happens.

How can I do this?

Many thanks
Matthew

(I really want to be able to add associated functions to the arrow keys)

0
Comment
Question by:CDP
3 Comments
 
LVL 8

Accepted Solution

by:
MikeP090797 earned 50 total points
Comment Utility
There is no built-in way how you can assign functions. What you can do is to put this code inside Form_KeyDown:

If KeyCode=vbKeyEnter then ProcessEnter
If KeyCode=vbKeyLeft then ProcessLeft
'And so On

Sub ProcessEnter
'process
End Sub

0
 

Author Comment

by:CDP
Comment Utility
Thanks Mike, I tried that and put some code in the processenter sub but it did not work. Do I have to declare vbKeyEnter somewhere?


0
 
LVL 3

Expert Comment

by:traygreen
Comment Utility
No, it is a vb constant.  Typically you would want to use the keydown event for the controls not the form.
You need to watch the shift value if you are sending keys other than <space>, <enter>, <tab> etc
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now