m(_ _)m
饶了我吧!~
饶了我吧!~
程序代码:
Option Explicit Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) Dim kUp As Boolean, kDown As Boolean, kLeft As Boolean, kRight As Boolean Dim b(0 To &HFF) As Byte '256 GetKeyboardState b(0) kUp = CBool(b(vbKeyUp) And &H80): kDown = CBool(b(vbKeyDown) And &H80) kLeft = CBool(b(vbKeyLeft) And &H80): kRight = CBool(b(vbKeyRight) And &H80) Debug.Print "kUp "; kUp, "kDown "; kDown, "kLeft "; kLeft, "kRight "; kRight Select Case True Case kUp And kLeft: Shape1.Move Shape1.Left - 100, Shape1.Top - 100 Case kUp And kRight: Shape1.Move Shape1.Left + 100, Shape1.Top - 100 Case kDown And kLeft: Shape1.Move Shape1.Left - 100, Shape1.Top + 100 Case kDown And kRight: Shape1.Move Shape1.Left + 100, Shape1.Top + 100 Case kUp: Shape1.Move Shape1.Left, Shape1.Top - 100 Case kDown: Shape1.Move Shape1.Left, Shape1.Top + 100 Case kLeft: Shape1.Move Shape1.Left - 100, Shape1.Top Case kRight: Shape1.Move Shape1.Left + 100, Shape1.Top End Select End Sub