Public Class Form1 Inherits System.Windows.Forms.Form Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Dim f As Form f = New Form f.Show() f = New frmRaceEm f.Show() f = New frmRaceEm f.ShowDialog() End Sub Private Sub btnSeeAnimated_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles btnSeeAnimated.Click Dim f As Form f = New Form2 f.Show() End Sub End Class Public Class frmRaceEm Inherits System.Windows.Forms.Form Dim racers(3) As Object Private Sub frmRaceEm_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load racers(0) = PictureBox1 racers(1) = PictureBox2 racers(2) = PictureBox3 End Sub Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Dim i As Integer For i = 0 To 2 racers(i).top = racers(i).top + i * 10 + 10 Next End Sub End Class Public Class Form2 Inherits System.Windows.Forms.Form Dim p(3) As Object Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Timer1.Enabled = Not Timer1.Enabled End Sub Function randomColor() As Color Dim red, green, blue As Integer red = Int(Rnd() * 256) green = Int(Rnd() * 256) blue = Int(Rnd() * 256) randomColor = Color.FromArgb(red, green, blue) End Function Private Sub Timer1_Tick(ByVal sdr As Object, ByVal e As System.EventArgs) _ Handles Timer1.Tick Dim i, randomChoice As Integer For i = 0 To 2 randomChoice = Int(Rnd() * ImageList1.Images.Count) p(i).Image = ImageList1.Images(randomChoice) If chkColorChanges.Checked Then p(i).BackColor = randomColor() End If Next End Sub Private Sub Form2_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles MyBase.Load p(0) = PictureBox1 p(1) = PictureBox2 p(2) = PictureBox3 End Sub Private Sub chkColorChanges_CheckedChanged(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles chkColorChanges.CheckedChanged Dim i As Integer If Not chkColorChanges.Checked Then For i = 0 To 2 p(i).Backcolor = Me.BackColor Next End If End Sub End Class 'ImageList1 ' Me.ImageList1.ImageSize = New System.Drawing.Size(50, 50) Me.ImageList1.ImageStream = __ CType(resources.GetObject("ImageList1.ImageStream"), _ System.Windows.Forms.ImageListStreamer) Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent ' 'PictureBox1 ' Me.PictureBox1.Location = New System.Drawing.Point(8, 16) Me.PictureBox1.Name = "PictureBox1" Me.PictureBox1.Size = New System.Drawing.Size(100, 80) Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage Me.PictureBox1.TabIndex = 0 Me.PictureBox1.TabStop = False ' 'Timer1 ' Me.Timer1.Interval = 1000 ' 'chkColorChanges ' Me.chkColorChanges.Location = New System.Drawing.Point(184, 48) Me.chkColorChanges.Name = "chkColorChanges" Me.chkColorChanges.TabIndex = 4 Me.chkColorChanges.Text = "Color Changes"