Draw Dots Solution
Public Class Form1
Dim Number As Integer = 0
Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles Me.MouseClick
Dim MyFont As New Font("Courier New", 12, FontStyle.Bold) 'Or do this in the design window
Dim Red, Green, Blue As Integer
Red = Rnd() * 255
Green = Rnd() * 255
Blue = Rnd() * 255
Dim MyBrush As New SolidBrush(Color.FromArgb(255, Red, Green, Blue)) 'random color brush
Me.CreateGraphics.FillEllipse(MyBrush, e.X, e.Y, 20, 20) 'draw the circle
MyBrush.Color = Color.FromArgb(255, 255 - Red, 255 - Green, 255 - Blue) 'change the brush color
Number = Number + 1 'increment the global number
Me.CreateGraphics.DrawString(Number, MyFont, MyBrush, e.X, e.Y) 'draw the number inside the circle
End Sub 'Form1_MouseClick
End Class
Note: This may not seem like a terribly useful project, but it lays the ground work for drawing graphs and charts on the fly from data retrieved from a file or a database later on.
INDEX,
Draw a circle,
The Brush,
Drawing rectangles,
Arc and Pie,
Array of Points,
Drawing Strings: The Font Class,
Numbered Dots Project,
Numbered Dots SolutionNext lesson:
Procedures in Visual Basic