Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Using Arrow Keys in VB5

Posted on 1998-08-30
5
Medium Priority
?
212 Views
Last Modified: 2010-04-30
I'd like to know how to detect the user pressing the arrow keys in vb5. A little example source would be plus :). And hey, it's worth 200 points.
0
Comment
Question by:loopdloop
[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
  • 4
5 Comments
 
LVL 3

Accepted Solution

by:
a111a111a111 earned 800 total points
ID: 1431851
Option Explicit

Private Sub Form_Load()
    KeyPreview = True
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyF1: MsgBox "F1 is your friend."
        Case vbKeyF2: MsgBox "F2 could copy text."
        Case vbKeyF3: MsgBox "F3 could paste text."
        Case vbKeyF4: MsgBox "F4 could format text."
        Case vbKeyF4: MsgBox "F4 could format text."
       
    End Select
End Sub

I am working on arrow keys
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1431852
And here is the answer:

Option Explicit

Private Sub Form_Load()
    KeyPreview = True
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyLeft: MsgBox "Left"
        Case vbKeyRight: MsgBox "Right"
        Case vbKeyUp: MsgBox "up"
        Case vbKeyDown: MsgBox "Down"
    End Select
End Sub


shay@hili.com
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1431853
One more:

if you add a label  here is a code :

'*======start============

Option Explicit

Private Sub Form_Load()
    KeyPreview = True
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyLeft: Label1.Caption = "Left"
        Case vbKeyRight: Label1.Caption = "Right"
        Case vbKeyUp: Label1.Caption = "up"
        Case vbKeyDown: Label1.Caption = "Down"
    End Select
End Sub

'*========== end ==========

shay@hili.com
0
 

Author Comment

by:loopdloop
ID: 1431854
thanx a bunch! enjoy the points :)
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1431855
It is my pleasure to help and assist you.

Shay.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

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

618 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