How to Draw Circle and Square in VB.Net

0
46

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.
    1. Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
    2. Using Brush1 As New SolidBrush(Color.RoyalBlue)
    3. e.Graphics.FillEllipse(Brush1, 20, 20, 200, 200)
    4. End Using
    5. Using Pen1 As New Pen(Color.Red, 10)
    6. e.Graphics.DrawEllipse(Pen1, 20, 20, 200, 200)
    7. End Using
    8. End Sub
  • Output:

  • Add this following codes to draw a square in the form.
    1. Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
    2. Dim square As New Rectangle(20, 20, 200, 200)
    3. Using Brush1 As New SolidBrush(Color.RoyalBlue)
    4. e.Graphics.FillRectangle(Brush1, square)
    5. End Using
    6. End Sub
  • 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:

 

 

 

 

Facebook Comments
(Visited 55 times, 1 visits today)

LEAVE A REPLY

Please enter your comment!
Please enter your name here