Solved

Keydown Question.

Posted on 1998-11-18
3
175 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Determine Range to Select 5 58
Adding to a VBA? 6 85
Hide vba in gp 7 118
Formula problem with Excel attachment 6 43
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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…

730 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