Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode Case vbKeyLeft Picture1.Left = Picture1.Left - 100 Case vbKeyUp Picture1.Top = Picture1.Top - 100 Case vbKeyDown Picture1.Top = Picture1.Top + 100 Case vbKeyRight Picture1.Left = Picture1.Left + 100 End Select If Picture1.Left < 0 Then Picture1.Left = 0 If Picture1.Top < 0 Then Picture1.Top = 0 If Picture1.Left > Me.ScaleWidth - Picture1.Width Then Picture1.Left = Me.ScaleWidth - Picture1.Width If Picture1.Top > Me.ScaleHeight - Picture1.Height Then Picture1.Top = Me.ScaleHeight - Picture1.Height End Sub
Private Sub Form_Load() Me.KeyPreview = True End Sub
这是用上下左右键控制图片移动的,我想要在我不按上下左右键时候图片也按上次移动的方向自动移动.