Solved

Keydown Question.

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses
Course of the Month8 days, 21 hours left to enroll

617 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