Guest User

Untitled

a guest
Jul 6th, 2014
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Class Form1
  2.  
  3.     Dim rng As New Random
  4.     Dim allPictureBoxes = Controls.OfType(Of PictureBox)()
  5.     Dim WithEvents randomPictureBox As PictureBox
  6.     Dim currentClickCount = 0
  7.  
  8.  
  9.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  10.         Label2.Hide()
  11.         Label2.Text = "0"
  12.         Button2.Hide()
  13.     End Sub
  14.  
  15.  
  16.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  17.         Timer1.Start()
  18.         Timer2.Start()
  19.         Button1.Hide()
  20.         Label2.Show()
  21.         Button2.Show()
  22.     End Sub
  23.  
  24.  
  25.     Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  26.         Timer1.Stop()
  27.         Dim allPictureBoxes = Controls.OfType(Of PictureBox)()
  28.         For Each PictureBox In allPictureBoxes
  29.             PictureBox.Image = My.Resources.boximage
  30.         Next
  31.         Label2.Text = "0"
  32.         currentClickCount = 0
  33.         Button2.Hide()
  34.         Button1.Show()
  35.     End Sub
  36.  
  37.  
  38.     Public Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  39.         Timer1.Interval = 1000
  40.         Dim allPictureBoxes = Controls.OfType(Of PictureBox)()
  41.         Dim randomisedPictureBoxes = allPictureBoxes.OrderBy(Function(pb) rng.NextDouble())
  42.         randomPictureBox = randomisedPictureBoxes.First()
  43.         randomPictureBox.Image = My.Resources.boximagelit
  44.         Label1.Text = ""
  45.     End Sub
  46.  
  47.     Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
  48.         Label2.Text = currentClickCount
  49.     End Sub
  50.  
  51.     Public Sub randomPictureBox_Click(sender As Object, e As EventArgs) Handles randomPictureBox.Click
  52.         randomPictureBox.Image = My.Resources.boximage
  53.         Label1.Text = "Box Clicked"
  54.         currentClickCount += 1
  55.     End Sub
  56.  
  57.  
  58. End Class
Advertisement
Add Comment
Please, Sign In to add comment