Ecco i codici del programma:
Public Class Form1
Dim spost As Integer
Dim pi As Integer
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
If spost = 3 Then
Panel1.Location = New Point(Panel1.Location.X + 5, Panel1.Location.Y)
Panel6.Location = New Point(Panel6.Location.X - 5, Panel6.Location.Y)
If Panel1.Location.X = pi + 50 Then
Timer1.Stop()
End If
ElseIf spost = 4 Then
Panel1.Location = New Point(Panel1.Location.X, Panel1.Location.Y + 5)
Panel6.Location = New Point(Panel6.Location.X, Panel6.Location.Y - 5)
If Panel1.Location.Y = pi + 50 Then
Timer1.Stop()
End If
ElseIf spost = 1 Then
Panel1.Location = New Point(Panel1.Location.X - 5, Panel1.Location.Y)
Panel6.Location = New Point(Panel6.Location.X + 5, Panel6.Location.Y)
If Panel1.Location.X = pi - 50 Then
Timer1.Stop()
End If
ElseIf spost = 2 Then
Panel1.Location = New Point(Panel1.Location.X, Panel1.Location.Y - 5)
Panel6.Location = New Point(Panel6.Location.X, Panel6.Location.Y + 5)
If Panel1.Location.Y = pi - 50 Then
Timer1.Stop()
End If
End If
End Sub