Solved

trapping arrow keys

Posted on 1998-08-20
2
202 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
ID: 1430071
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
ID: 1430072
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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

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…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

821 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