Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

I'm still having problems getting the keypress to work

Boogy_ManBoogy_Man Member Posts: 4
Even though mfroeb told me to type:
--
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyLeft Then
Paddle.Left = Paddle.Left - 75
End If
If KeyAscii = vbKeyRight Then
Paddle.Left = Paddle.Left + 75
End If
End Sub
--
YA SO I HAVE NO IDEA WHAT TO DO NOW. THIS SHOULD MAKE THE PADDLE GO LEFT OR RIGHT DEPENDING ON WHICH BUTTON YOU PUSH.

Comments

  • lionblionb Member Posts: 1,688 ✭✭
    : Even though mfroeb told me to type:
    : --
    : Private Sub Form_KeyPress(KeyAscii As Integer)
    : If KeyAscii = vbKeyLeft Then
    : Paddle.Left = Paddle.Left - 75
    : End If
    : If KeyAscii = vbKeyRight Then
    : Paddle.Left = Paddle.Left + 75
    : End If
    : End Sub
    : --
    : YA SO I HAVE NO IDEA WHAT TO DO NOW. THIS SHOULD MAKE THE PADDLE GO LEFT OR RIGHT DEPENDING ON WHICH BUTTON YOU PUSH.
    :
    Not sure what's your problem. That code did not work? What is Paddle? In my example it's Command button.
    First of all, set Form KeyPreview property to true. Do not use Key_press event. Instaed use Key_Down. Then write code like that and try it

    [code]Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 39 Then
    Paddle.Left = Paddle.Left - 75
    End If
    If KeyCode = 37 Then
    Paddle.Left = Paddle.Left + 75
    End If
    End Sub[/code]
  • Chris BrownChris Brown USAMember Posts: 4,624 ✭✭

    _________ [ http://forcoder.org ] free ebooks and video tutorials about ( Visual Basic Ruby Swift C# PL/SQL PHP Scratch Python R Perl Objective-C Visual Basic .NET JavaScript MATLAB Go C++ Delphi Assembly Java C Prolog LabVIEW Ada Logo Transact-SQL Alice Erlang VBScript SAS Dart Crystal F# Apex ML Julia Fortran COBOL Scala FoxPro Lisp D Clojure Kotlin Scheme Bash Awk ABAP Lua Rust Hack ) __________

Sign In or Register to comment.