Solved

trapping arrow keys

Posted on 1998-08-20
1
312 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
[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
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
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 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…

728 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