ERLEDIGT
NEIN
NEIN
ANTWORTEN
1
1
ZUGRIFFE
895
895
EMPFEHLEN
-
Hi.
Ich hab ein Problem bei diesem Code
Code :1 2 3 4 5 6 7 8 9 10 11
Public Class Form1 Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown PictureBox1.Top = PictureBox1.Top + 1 End Sub Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp PictureBox1.Top = PictureBox1.Top - 1 End Sub End Class
Ich möchte, dass wennich die Pfeiltaste nach unten drücke, dass die Picturebox um 1 nach unten geht und wenn ich nach Oben drücke, die pb um eins nach Oben geht.
Nur leider bleibt sie, wenn ich die Pfeiltaste nach oben drücke auf der Stelle stehen.
Besser gesagt sie geht um eins Hoch und sofort um eins wider runter, was mache ich falsch?
-
14.08.09 15:30 #2
- Registriert seit
- Aug 2001
- Ort
- Österreich, Stmk, Graz
- Beiträge
- 2.783
Die Events KeyDown und KeyUp werden ausgelöst wenn irgendeine Taste gedrückt bzw. losgelassen wird.
Für das was du vorhast, brauchst nur das KeyUp Event abfragen, und dort über das KeyEventArgs Objekt prüfen, welche Taste gedrückt wurde.
Code vb:1 2 3 4 5 6 7 8
Public Sub Form1_KeyUp(ByVal sender As Object, ByVal e As KeyEventArgs) Select Case (e.Key) Case Keys.Up PictureBox1.Top = PictureBox1.Top - 1 Case Keys.Down PictureBox1.Top = PictureBox1.Top + 1 End Select End Sub
lg,..With the first link the chain is forged. The first speech censored, the first thought forbidden, the first freedom denied, chains us all irrevocably.
Aaron Satie
Legends... are the spice of the universe, Mr. Data, because they have a way of sometimes coming true.
Captain Jean-Luc Picard, Stardate ~41294.5
Tutorials.de chattet. Hier gibts auch .net Support ^^
Klickt auf chattet und nutzt den Webchat, oder verbindet euch zu irc.tutorials.de - Channel #Tutorials.de
(moo)blog furred.net // SiteInfo für WP7 // Pastebin für WP7 // BlogEngine.net Extensions
Ähnliche Themen
-
Form1
Von Nikolaus1 im Forum .NET Windows FormsAntworten: 3Letzter Beitrag: 07.11.10, 11:52 -
Form1.Keyup und Form1.KeyDown-Problem
Von PH234X im Forum Visual Basic 6.0Antworten: 1Letzter Beitrag: 13.08.09, 17:59 -
Problem mit Form1 aktualisierung
Von davejarjarbinks im Forum .NET Windows FormsAntworten: 12Letzter Beitrag: 08.05.08, 22:00 -
Problem mit Form1 schließen nach 10 Min
Von AirsoftDivisionHRO im Forum Visual Basic 6.0Antworten: 10Letzter Beitrag: 24.10.07, 23:01 -
Funktion aus Form1.h in Form1.cpp auslagern
Von dertobian im Forum C/C++Antworten: 9Letzter Beitrag: 15.06.07, 12:59





Zitieren

Login





