Printing in VB

Circle Statement

The other major command is Circle, which allows you to draw a circle, ellipse or an arc. The circle statement uses the following syntax:

Printer.Circle [Step] (x, y), radius, [color, start, end, aspect]

As you can see, there are once again plenty of options. The (x, y) part specifies the centre of the circle to be drawn. As in the Line function, using the Step option means that these x and y coordinates will be taken relative to CurrentX and CurrentY. The radius parameter specifies the radius of the circle (that is the distance from its centre to its edge). There are then a number of optional parameters. color specifies the colour of the circle in RGB (red green blue). The start and end parameters allow you to draw a partial circle, or rather an ellipse or arc. start specifies the start of the arc, in radians (see note), and end specifies the end of the arc, in radians. Finally, the aspect option allows you to change the aspect ratio of the circle. A value of 1 is a perfect circle, a value of 1.5 is an ellipse.

Note
Radians are a used to measure angles. 1 radian is (180/pi)°. 360°= 2 * pi

Now lets take a look at a few examples.

Printer.Circle (3000, 3000), 1000, RBG(100, 30, 30)

Draws a circle like this:

To fill a circle you will need to change the FillStyle option, which is discussed in the next section.

Using the end and start properties, we can create arcs.

Note
As radians are closely related to pi, and the pi constant is used for the end and start parameters, add the following declaration to your project:
Const pi = 3.141592654

This code

Printer.Circle (3000, 3000), 1000, vbBlue, 0, pi

draws the following arc:

If you provide negative values, VB draws a line to the center of the circle too. For example,

Printer.Circle (3000, 3000), 1000, vbBlue, -1, -pi

draws the following:

Finally, using the aspect option, we can draw an ellipse. For example,

Printer.Circle (3000, 3000), 1000, vbBlue, , , 0.5

outputs

You might also like...

Comments

About the author

James Crowley

James Crowley United Kingdom

James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audien...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Debugging is anticipated with distaste, performed with reluctance, and bragged about forever.” - Dan Kaminsky