Solved

trapping arrow keys

Posted on 1998-08-20
2
199 Views
Last Modified: 2011-10-03
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
2 Comments
 
LVL 1

Accepted Solution

by:
blwatkins earned 100 total points
Comment Utility
In the KeyDown Event you can evaluate the KeyCode value to
see what key was pressed such as:

Private Sub Grid1_KeyDown(KeyCode As Integer, Shift As Integer)
  Select Case KeyCode
    Case 39   ' Right
      'Do Code for Moving Right
    Case 37   ' Left
      'Do Code for Moving Left
    Case 38   ' UP
      'Do Code for Moving UP
    Case 40   ' Down
      'Do Code for Moving Down
  End Select
End Sub


You can also use the VB Predefind values (I'm not sure if thay are available in VB4-16, but if so, it makes the code look a little better, and is easier to read.  (vbKeyUP, vbKeyDown, vbKeyRight, vbKeyLeft).


0
 
LVL 4

Expert Comment

by:mcix
Comment Utility
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
   
    Select Case KeyCode
   
        Case 37
            ' Left Arrow
        Case 38
            ' Up Arrow
        Case 39
            ' Right Arrow
        Case 40
            ' Down Arrow
    End Select
   
End Sub

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…

763 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

12 Experts available now in Live!

Get 1:1 Help Now