Solved

trapping arrow keys

Posted on 1998-08-20
2
204 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
[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
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

695 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