Drawing in Visual Basic

lines
Some of the graphics methods use points. A point is a class that has members X and Y. When you declare an instance of the Point or PointF class, you give X and Y as the arguments.
The DrawLine method has 4 possible argument lists.






The code below uses the fourth format:

Public Class Form1
    Private Sub Form1_MouseClick(sender As Object, e As MouseEventArgs) Handles Me.MouseClick
        Dim MyPoint1 As New Point(e.X - 10, e.Y - 10)
        Dim MyPoint2 As New Point(e.X + 10, e.Y + 10)
        Dim MyPen As New Pen(Color.Goldenrod, 3)
        Me.CreateGraphics.DrawLine(MyPen, MyPoint1, MyPoint2)
    End Sub
End Class

NEXT: Arc and Pie