## The Circle Method

 Enter your search terms Submit search form

Today I will discuss with you how to use the circle method to draw various shapes related to circle. The circle method can be used to draw a circle, a sector, an arc and an ellipse.

Before we use the circle, we also need to set the scale mode of the form. The default coordinate of the origin  is (0,0) from the upper left corner and the default scale is measured in twips, where an inch is equivalent to 1440 twips or 1 cm=567 twips. You can set the scale mode to user-defined, inch, centimeters and etc. Let say we set the scale mode to centimeter, so we can draw circle, sector, arc and ellipse in the following formats:

i)  Circle (x, y ),r    will draw a circle with coordinates (x,y) and radius r.

ii) Circle (x,y),r, color,-angle1,-angle2  where angle1 and angle 2 are measured in radians.

iii) Circle (x,y),r, color,angle1,angle2  where angle1 and angle 2 are measured in radians.    (Notice that the signs in front  of the angles are positive)

iv) Circle (x, y ),r ,color,,,ratio   will draw an ellipse with certain ratio

Examples are illustrated below:

 Private Sub cmd_Arc_Click() Dim PI As Single PI = 4 * Atn(1) Circle (6, 4), 2, vbRed, 0, PI / 2 End Sub Private Sub cmd_circle_Click() Circle (5, 5), 2 End Sub Private Sub cmd_ellipse_Click() PI = 4 * Atn(1) Circle (7, 7), 3, vbBlue, , , 0.5 End Sub Private Sub cmd_sector_Click() Dim PI As Single PI = 4 * Atn(1) Circle (3, 3), 3, vbRed, -PI / 2, -PI End Sub The value of PI can be computed using 4*Atn(1), as Atn(1) is 45 degree or PI/4 in radian. 　 The colors of the circle , sector, arc and ellipse can be specified with VB constant such as VbRed, VbBlue, VbGreen and etc.

[Back to VBToday]