Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: austintav on Aug 3rd, 2012  |  syntax: None  |  size: 1.40 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Public Class Form1
  2.     Dim PenUse As Integer
  3.     Dim Point1(1) As Integer
  4.     Dim Point2(2) As Integer
  5.     Dim formSurface As Graphics = Me.CreateGraphics
  6.     Dim pen1 As New Pen(Color.Red, 10)
  7.     Dim Pen2 As New Pen(Color.Blue, 20)
  8.     Dim Pen3 As New Pen(Color.Green, 40)
  9.  
  10.  
  11.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  12.         Randomize()
  13.         PenUse = Int((3 - 1 + 1) * Rnd() + 3)
  14.         Point1(0) = Int((180 - 20 + 1) * Rnd() + 20)
  15.         Point1(1) = Int((180 - 20 + 1) * Rnd() + 20)
  16.         Point2(0) = Int((180 - 20 + 1) * Rnd() + 20)
  17.         Point2(1) = Int((180 - 20 + 1) * Rnd() + 20)
  18.  
  19.  Select PenUse
  20.             Case 1
  21.                 formSurface.DrawLine(pen1, Point1(0), Point1(1), Point2(0), Point2(1))
  22.             Case 2
  23.                 formSurface.DrawLine(Pen2, Point1(0), Point1(1), Point2(0), Point2(1))
  24.             Case 3
  25.                 formSurface.DrawLine(Pen3, Point1(0), Point1(1), Point2(0), Point2(1))
  26.         End Select
  27.     End Sub
  28.  
  29.     Private Sub btnFaster_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFaster.Click
  30.         Me.Timer1.Interval = Me.Timer1.Interval - 10
  31.     End Sub
  32.  
  33.     Private Sub btnSlower_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSlower.Click
  34.         Me.Timer1.Interval = Me.Timer1.Interval + 10
  35.     End Sub
  36. End Class