How to move a picture on a form with the arrow-keys?


This is an example. Put one picture-box on a new form and use the following code in the picture-box's keydown-event:

Select Case KeyCode
    Case vbKeyUp:
    Picture1.Top = Picture1.Top - 100
    Case vbKeyDown:
    Picture1.Top = Picture1.Top + 100
    Case vbKeyLeft:
    Picture1.Left = Picture1.Left - 100
    Case vbKeyRight:
    Picture1.Left = Picture1.Left + 100
End Select




Mail to Daniel Wiman <daniel@wimania.com>
Online since June 1996, updated 990314
<- The VB home
<- Daniels homepage