?
Solved

trapping arrow keys

Posted on 1998-08-20
2
Medium Priority
?
205 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 200 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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 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…
Suggested Courses
Course of the Month8 days, 13 hours left to enroll

764 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