How to Draw Circle and Square in VB.Net

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:

Basic Shapes to Draw
We’ll continue our namespace research by drawing some simple shapes. Again, the namespace’s diversity and features are remarkable; we’ll attempt to stick to the shapes and image details you’re most likely to utilize in your program.

In Visual Basic, how do you draw a shape?

How to Draw a Circle and a Square in VB.Net image

To draw a shape, simply click on the shape control and draw your desired shape on the form. The default shape is a rectangle with a value of 0 for the default shape attribute. By adjusting the shape property’s value to 1, 2, 3, 4, and 5 accordingly, you may change the shape to square, oval, circle, and rounded rectangle.

  • 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 Comment