-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmoving_object.vb
53 lines (46 loc) · 1.38 KB
/
moving_object.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Public Class moving_object
'start button
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Timer1.Interval = 300
Timer1.Enabled = True
End Sub
'stop button
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Timer1.Enabled = False
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
'left
If (RadioButton1.Checked) Then
' PictureBox1.Left -= 30
If PictureBox1.Left > 0 Then
PictureBox1.Left -= 30
Else
PictureBox1.Left = Me.Width
End If
End If
'Right
If (RadioButton2.Checked) Then
If PictureBox1.Left < Me.Width Then
PictureBox1.Left += 30
Else
PictureBox1.Left = 0
End If
End If
'Up
If (RadioButton3.Checked) Then
If PictureBox1.Top > 0 Then
PictureBox1.Top -= 30
Else
PictureBox1.Top = Me.Height
End If
End If
'Down
If (RadioButton4.Checked) Then
If PictureBox1.Top < Me.Height Then
PictureBox1.Top += 30
Else
PictureBox1.Top = 0
End If
End If
End Sub
End Class