How to Draw Circle and Square in VB.Net

0
846

This Tutorial is all about How to Draw Circle and Square in VB.Net. In this tutorial about How to Draw Circle and Square in VB.Net, you will be able to Draw Circle and Square in VB.Net. So lets get Started:

  • First is open the Visual Basic, Select File on the menu, then click New and create a new project.

  • Then a New Project Dialog will appear. You can rename your project, depending on what you like to name it. After that click OK

  • After that, design your form like this just like what I’ve shown you below.
  • Add this following codes to draw a circle in the form.
    [vbnet]
    Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
    Using Brush1 As New SolidBrush(Color.RoyalBlue)
    e.Graphics.FillEllipse(Brush1, 20, 20, 200, 200)
    End Using
    Using Pen1 As New Pen(Color.Red, 10)
    e.Graphics.DrawEllipse(Pen1, 20, 20, 200, 200)
    End Using
    End Sub
    [/vbnet]
  • Output:

  • Add this following codes to draw a square in the form.
    [vbnet]
    Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
    Dim square As New Rectangle(20, 20, 200, 200)
    Using Brush1 As New SolidBrush(Color.RoyalBlue)
    e.Graphics.FillRectangle(Brush1, square)
    End Using
    End Sub
    [/vbnet]
  • Output:

 

 

If you have any comments or suggestions about on How to Draw Circle and Square in VB.Net, please feel free to contact our webpage.

Download How to Draw Circle and Square in VB.Net Here

Other Articles Readers might read:

 

 

 

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.