Guten Tag Breadfish,
Ich hab ein kleines problem mit Visual Basic hab erst gestern damit angefangen zu arbeiten und wollte etwas leichtes mal ausprobieren.
Nun kann ich wenn ich in mein Feld eine "1" eingeben und dann den Button 1 drücke passiert nichts obwohl mein Auto dann speed nach vorne geben soll.
Hier der ganze Code:
Code
Public Class Form1
Dim speed As Integer = 1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
PictureBox2.Left -= speed
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
PictureBox2.Left += speed
End Sub
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.Left Then
Timer1.Enabled = True
End If
If e.KeyCode = Keys.Right Then
Timer2.Enabled = True
End If
End Sub
Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
Try
Timer1.Enabled = False
Timer2.Enabled = False
Catch ex As Exception
End Try
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
speed = 1
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
speed = 3
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
speed = 5
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
speed = 10
End Sub
End Class
Alles anzeigen
Hab noch rasch 2 Errors behoben aber es klappt immer noch nicht
Mit freundlichen Grüßen
IceboyTea