Xboxerdude
Member
- Joined
- Jul 6, 2008
- Sythe Gold
- 0
- Messages
- 41
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Button2 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.PictureBox1 = New System.Windows.Forms.PictureBox
Me.Button1 = New System.Windows.Forms.Button
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.Button2 = New System.Windows.Forms.Button
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'PictureBox1
'
Me.PictureBox1.Location = New System.Drawing.Point(40, 8)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(200, 200)
Me.PictureBox1.TabIndex = 0
Me.PictureBox1.TabStop = False
'
'Button1
'
Me.Button1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button1.Location = New System.Drawing.Point(80, 280)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(112, 32)
Me.Button1.TabIndex = 1
Me.Button1.Text = "Play"
'
'TextBox1
'
Me.TextBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.TextBox1.Location = New System.Drawing.Point(80, 336)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(112, 22)
Me.TextBox1.TabIndex = 2
Me.TextBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(32, 336)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(40, 23)
Me.Label1.TabIndex = 3
Me.Label1.Text = "Tries"
'
'Button2
'
Me.Button2.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button2.Location = New System.Drawing.Point(80, 224)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(112, 32)
Me.Button2.TabIndex = 4
Me.Button2.Text = "New Game"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(280, 378)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.PictureBox1)
Me.Name = "Form1"
Me.Text = "Target"
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim g As Graphics = PictureBox1.CreateGraphics
Dim X As Integer = 0
Dim Y As Integer = 0
Dim Count As Integer
Dim MyPen As New Pen(Color.Black)
Dim RanNum As Integer
Dim MyRandomGenerator As System.Random
MyRandomGenerator = New System.Random
'keep looking until the coordinates if the hit attempt
'match the coordinates of the center point of the target
' at 100 by 100 in the picture box
Do Until X = 100 And Y = 100
Count = Count + 1
'generate the x cordinate of the hit attempt
X = MyRandomGenerator.Next(0, 200)
'generate the y cordinate of the hit attempt
Y = MyRandomGenerator.Next(0, 200)
'a circle 1 pixel in size at the x, y location
g.DrawEllipse(MyPen, New Rectangle(X, Y, 1, 1))
Loop
TextBox1.Text = Count
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim g As Graphics = PictureBox1.CreateGraphics
Dim MyPen As New Pen(Color.Red)
Dim X As Integer
Dim Y As Integer
MyPen.Width = 1
MyPen.Color = Color.White
For X = 0 To 200
For Y = 0 To 200
g.DrawEllipse(MyPen, New Rectangle(X, Y, 1, 1))
Next
Next
MyPen.Width = 4
MyPen.Color = Color.Red
g.DrawEllipse(MyPen, New Rectangle(90, 90, 20, 20))
g.DrawEllipse(MyPen, New Rectangle(80, 80, 40, 40))
g.DrawEllipse(MyPen, New Rectangle(70, 70, 60, 60))
g.DrawEllipse(MyPen, New Rectangle(60, 60, 80, 80))
MyPen.Width = 1
g.DrawEllipse(MyPen, New Rectangle(100, 100, 1, 1))
TextBox1.Text = ""
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Button2 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.PictureBox1 = New System.Windows.Forms.PictureBox
Me.Button1 = New System.Windows.Forms.Button
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.Button2 = New System.Windows.Forms.Button
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'PictureBox1
'
Me.PictureBox1.Location = New System.Drawing.Point(40, 8)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(200, 200)
Me.PictureBox1.TabIndex = 0
Me.PictureBox1.TabStop = False
'
'Button1
'
Me.Button1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button1.Location = New System.Drawing.Point(80, 280)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(112, 32)
Me.Button1.TabIndex = 1
Me.Button1.Text = "Play"
'
'TextBox1
'
Me.TextBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.TextBox1.Location = New System.Drawing.Point(80, 336)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(112, 22)
Me.TextBox1.TabIndex = 2
Me.TextBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(32, 336)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(40, 23)
Me.Label1.TabIndex = 3
Me.Label1.Text = "Tries"
'
'Button2
'
Me.Button2.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button2.Location = New System.Drawing.Point(80, 224)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(112, 32)
Me.Button2.TabIndex = 4
Me.Button2.Text = "New Game"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(280, 378)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.PictureBox1)
Me.Name = "Form1"
Me.Text = "Target"
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim g As Graphics = PictureBox1.CreateGraphics
Dim X As Integer = 0
Dim Y As Integer = 0
Dim Count As Integer
Dim MyPen As New Pen(Color.Black)
Dim RanNum As Integer
Dim MyRandomGenerator As System.Random
MyRandomGenerator = New System.Random
'keep looking until the coordinates if the hit attempt
'match the coordinates of the center point of the target
' at 100 by 100 in the picture box
Do Until X = 100 And Y = 100
Count = Count + 1
'generate the x cordinate of the hit attempt
X = MyRandomGenerator.Next(0, 200)
'generate the y cordinate of the hit attempt
Y = MyRandomGenerator.Next(0, 200)
'a circle 1 pixel in size at the x, y location
g.DrawEllipse(MyPen, New Rectangle(X, Y, 1, 1))
Loop
TextBox1.Text = Count
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim g As Graphics = PictureBox1.CreateGraphics
Dim MyPen As New Pen(Color.Red)
Dim X As Integer
Dim Y As Integer
MyPen.Width = 1
MyPen.Color = Color.White
For X = 0 To 200
For Y = 0 To 200
g.DrawEllipse(MyPen, New Rectangle(X, Y, 1, 1))
Next
Next
MyPen.Width = 4
MyPen.Color = Color.Red
g.DrawEllipse(MyPen, New Rectangle(90, 90, 20, 20))
g.DrawEllipse(MyPen, New Rectangle(80, 80, 40, 40))
g.DrawEllipse(MyPen, New Rectangle(70, 70, 60, 60))
g.DrawEllipse(MyPen, New Rectangle(60, 60, 80, 80))
MyPen.Width = 1
g.DrawEllipse(MyPen, New Rectangle(100, 100, 1, 1))
TextBox1.Text = ""
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class





