Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class DrawPolygon
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
public class Form1
Inherits System.Windows.Forms.Form
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim g As Graphics = e.Graphics
' Create pens
Dim greenPen As New Pen(Color.Green, 2)
Dim redPen As New Pen(Color.Red, 2)
' Create points for polygon.
Dim p1 As New PointF(40.0F, 50.0F)
Dim p2 As New PointF(60.0F, 70.0F)
Dim p3 As New PointF(80.0F, 34.0F)
Dim p4 As New PointF(120.0F, 180.0F)
Dim p5 As New PointF(200.0F, 150.0F)
Dim ptsArray As PointF() = {p1, p2, p3, p4, p5}
' Draw polygon
e.Graphics.DrawPolygon(greenPen, ptsArray)
' Dispose
greenPen.Dispose()
redPen.Dispose()
End Sub
Public Sub New()
MyBase.New()
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
End Sub
End Class