Computing.Net > Forums > Programming > Arrow keys

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Arrow keys

Reply to Message Icon

Name: browser
Date: March 15, 2005 at 06:56:45 Pacific
OS: XP
CPU/Ram: Pentium 64 MB
Comment:

Hello,
I created a program in Visual Basic 6.0 (DAO) in which I have placed all of my controls onto a picture box. I have added scroll bars to the picture box and the scroll bars work. My question is, how do I make it so that the up and down arrow keys as well as the page up and page down keys work also. Any help would be greatly appreciated. Thank you.

browser



Sponsored Link
Ads by Google

Response Number 1
Name: livingdecay
Date: March 15, 2005 at 10:38:15 Pacific
Reply:

Use the 'OnKeyDown' event of the PicBox. The argument 'Key' or 'Button' (cant remember which) receives the keyascii that was pressed. so...

If Key = [up key ascii num, look up in msdn] then
do whatever
End If

You may have to play around a bit, this is a general guideline as I haven't programmed VB for a little while and it's not installed on my PC right now.

AMD Athlon 64 S939 3000+
ASUS A8V Deluxe WE MoBo
20Gb + 80Gb ATA133 HDD
Leadtek geforce 6800 128Mb
ThermalTake 360W PurePower PSU



0

Response Number 2
Name: egkenny
Date: March 15, 2005 at 17:30:26 Pacific
Reply:

If you look up KeyCode in VB help you are given a list of constants to use. For example:

' vbKeyUp = UP ARROW key
' vbKeyDown = DOWN ARROW key
' vbKeyPageUp = PAGE UP key
' vbKeyPageDown = PAGE DOWN key

Private Sub Picture1_KeyDown(KeyCode As Integer, Shift As Integer) '
If KeyCode = vbKeyUp Then
Debug.Print "UP ARROW key was pressed"
ElseIf KeyCode = vbKeyDown Then
Debug.Print "DOWN ARROW key was pressed"
ElseIf KeyCode = vbKeyPageUp Then
Debug.Print "PAGE UP key was pressed"
ElseIf KeyCode = vbKeyPageDown Then
Debug.Print "PAGE DOWN key was pressed"
End If
End Sub


0

Response Number 3
Name: browser
Date: March 16, 2005 at 06:07:52 Pacific
Reply:

Thanks livingdecay and egkenny, your answers were very helpful and everything works now.

browser


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Arrow keys

Best way to use keys for actions www.computing.net/answers/programming/best-way-to-use-keys-for-actions/10895.html

Multiple key presses in JavaScript www.computing.net/answers/programming/multiple-key-presses-in-javascript/10927.html

changing the color of Turbo c++ www.computing.net/answers/programming/changing-the-color-of-turbo-c-/13874.html