Solved

trapping arrow keys

Posted on 1998-08-20
1
306 Views
Last Modified: 2012-05-04
I would like the user to be able to use the arrow keys to manuver around a series of textboxes.
But I can't find the appropriate Ascii codes for them.
How can I let the user move around my program by just using the arrow keys?
With code please...
This is in VB4-16bit.
0
Comment
Question by:dtucker
1 Comment
 
LVL 1

Accepted Solution

by:
jsuper earned 100 total points
ID: 1430070
Use the keyup or keydown event for each of the controls.  Then use the vbcode constants to detect the arrow keys. (See below).  Note that the keypress routine will NOT work, because it returns the ASCII value which is not the same thing as the keycode value.

Option Explicit

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyDown
            MsgBox "Down"
        Case vbKeyUp
            MsgBox "Up"
        Case vbKeyLeft
            MsgBox "Left"
        Case vbKeyRight
            MsgBox "Right"
    End Select
End Sub

If you need more of an explanation, just add a comment...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…

939 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

10 Experts available now in Live!

Get 1:1 Help Now