Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Keydown Question.

Posted on 1998-11-18
3
Medium Priority
?
192 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 150 total points
ID: 1445499
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
ID: 1445500
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
ID: 1445501
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

926 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