Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- Dim rng As New Random
- Dim allPictureBoxes = Controls.OfType(Of PictureBox)()
- Dim WithEvents randomPictureBox As PictureBox
- Dim currentClickCount = 0
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- Label2.Hide()
- Label2.Text = "0"
- Button2.Hide()
- End Sub
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- Timer1.Start()
- Timer2.Start()
- Button1.Hide()
- Label2.Show()
- Button2.Show()
- End Sub
- Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
- Timer1.Stop()
- Dim allPictureBoxes = Controls.OfType(Of PictureBox)()
- For Each PictureBox In allPictureBoxes
- PictureBox.Image = My.Resources.boximage
- Next
- Label2.Text = "0"
- currentClickCount = 0
- Button2.Hide()
- Button1.Show()
- End Sub
- Public Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
- Timer1.Interval = 1000
- Dim allPictureBoxes = Controls.OfType(Of PictureBox)()
- Dim randomisedPictureBoxes = allPictureBoxes.OrderBy(Function(pb) rng.NextDouble())
- randomPictureBox = randomisedPictureBoxes.First()
- randomPictureBox.Image = My.Resources.boximagelit
- Label1.Text = ""
- End Sub
- Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
- Label2.Text = currentClickCount
- End Sub
- Public Sub randomPictureBox_Click(sender As Object, e As EventArgs) Handles randomPictureBox.Click
- randomPictureBox.Image = My.Resources.boximage
- Label1.Text = "Box Clicked"
- currentClickCount += 1
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment