Solved

Using Arrow Keys in VB5

Posted on 1998-08-30
5
193 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
  • 4
5 Comments
 
LVL 3

Accepted Solution

by:
a111a111a111 earned 200 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
thanx a bunch! enjoy the points :)
0
 
LVL 3

Expert Comment

by:a111a111a111
Comment Utility
It is my pleasure to help and assist you.

Shay.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

772 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

10 Experts available now in Live!

Get 1:1 Help Now