0% found this document useful (0 votes)
10 views

Bouncing Ball

The document describes adding code to move a picture box around a form using timers. It changes the form's size mode to zoom, adds 4 timers set to interval of 1 second, and sets the first timer to enabled. Code is added to each timer's tick event to move the picture box 5 pixels in a direction, and change to the next timer if it reaches the form boundaries.

Uploaded by

Partha Boyal
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Bouncing Ball

The document describes adding code to move a picture box around a form using timers. It changes the form's size mode to zoom, adds 4 timers set to interval of 1 second, and sets the first timer to enabled. Code is added to each timer's tick event to move the picture box 5 pixels in a direction, and change to the next timer if it reaches the form boundaries.

Uploaded by

Partha Boyal
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Change also Size Mode to Zoom Add 4 timers to the form.

Change their interval property to 1 Change also the first timer Enabled property to True Let's add the code to each timer tick event: Timer1.Tick
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.Even tArgs) Handles Timer1.Tick PictureBox1.Location = New Point(PictureBox1.Location.X + 5, PictureBox1.Location.Y + 5) If PictureBox1.Location.X + PictureBox1.Width > Me.Width Then Timer1.Stop() Timer2.Start() End If If PictureBox1.Location.Y + PictureBox1.Height > Me.Height Then Timer1.Stop() Timer3.Start() End If End Sub

Timer2.Tick
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.Even tArgs) Handles Timer2.Tick PictureBox1.Location = New Point(PictureBox1.Location.X - 5, PictureBox1.Location.Y + 5) If PictureBox1.Location.Y + PictureBox1.Height > Me.Height Then Timer2.Stop() Timer4.Start() End If If PictureBox1.Location.X < 0 Then Timer2.Stop() Timer1.Start() End If End Sub

Timer3.Tick
Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.Even tArgs) Handles Timer3.Tick PictureBox1.Location = New Point(PictureBox1.Location.X + 5, PictureBox1.Location.Y - 5) If PictureBox1.Location.X + PictureBox1.Width > Me.Width Then Timer3.Stop() Timer4.Start() End If If (PictureBox1.Location.Y < 0) Then Timer3.Stop() Timer1.Start() End If

End Sub

Timer4.Tick
Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.Even tArgs) Handles Timer4.Tick PictureBox1.Location = New Point(PictureBox1.Location.X - 5, PictureBox1.Location.Y - 5) If PictureBox1.Location.X < 0 Then Timer4.Stop() Timer3.Start() End If If (PictureBox1.Location.Y < 0) Then Timer4.Stop() Timer2.Start() End If End Sub

You might also like