Solved

Keydown Question.

Posted on 1998-11-18
3
174 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
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

860 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