Answer: – Visual basic supports different types of graphic files. The stored graphic file can easily call by image and picture control tools. They are .bmp, .emf, .gif, .ico, .jpg or .wmf. An image control and picture box control hold a picture it is a rectangular portion into which graphics files can be loaded. We can set an image’s picture properties to a file with an extension of .bmp, .wmf, .dib, .gif, .jpg, .emf or .cur. First place the image control on a form and the select its picture property in the property window.
The picture box control is similar to the image control, but picture box does not contain a scratch properties. However, it does have many other properties for graphics including those relating to the scale. Picture boxes use more system resource than image use. For that reason, the recommended practice is to use an image control unless we need the added capabilities of picture box.
Visual basic provides graphics methods for drawing points, lines, boxes and circle directly on a form, a picture box control or to the printer. Although these methods may use to draw graphics directly on a form, we will use the picture box control because it serves as a convenient container for graphics. The prefix for picture box control name is pic.
The line method draws a line or box. We will use the following general format of the method to draw a line. Syntax of line method is –
object.Line(x1,y1) – (x2,y2)[,color]
Other, object is the name of the control on which line drawn X1 and Y1 are the coordinates of the line’s starting points. X2 and Y2 are the coordinates of the line’s ending point color is an optional argument specifying the color of the point if the color argument is omitted, the line will appear in the color specified by the objects forecolor properties.
For example, the following statements draw a blue line from (100,200) to (500,200) on the PicGraphics control.
PicGraphics.Line(100,200) – (500,200), vbBlue
And the following statement draws a line from (0,0) to (1000,1000) using the color returned from the RGB function.
PicGraphics.Line(0,0) – (1000,1000), RGB (175,60,200)
The circle method draws a circle we will use the following general format of the method to draw a line. Syntax of circle method is –
Here, object is the name of the control on which the circle is drawn. X and Y are the coordinates of the circle’s center point. Radius is the circle’s radius color is an optional argument specifying the color of the circle’s outline. If the color argument is omitted, the circle will appear in the color specified by object’s fore color property.
For example, the following statement draw a green circle with a radius of 1000. The center of the is at (500,500)
As with boxes, an object’s fill style and fill color property setting determine how a circle is filled for example, the following code sets the PicGraphics control’s Fill Style property to solid, and its Fill color properties to green, then draws a circle with a green online. Because the fill style property in set a solid, the circle will be filled with the color specified in the fill color property which is green.