Thursday 12 May 2011

How To Use the Draw Command in Visual Basic

Visual Basic is a third generation programming language that allows a programmer to create an application. It is very easy to learn and quite simple to use. One important component of programming done in VB is the graphics because it makes the interface more attractive to the user. Before any of the improvements, designing graphics and drawing in BASIC was considered to be so time consuming and difficult because each line had to be programmed. With the improved version, creating graphics has been made much easier. Instead of having to type the code for making a dot or a box, you just need to click on the Draw command and choose whether you want to create a line, box, or just draw in freeform.

* Click on line control to create a straight line. Drawing using Visual Basic is almost the same as drawing using any other drawing software. Once you click on the Draw command, the drawing toolbar will launch. Select line control and draw a line on the form that you have already created using your mouse. Once you are done making the line, you can change the color in BorderColor. You can also alter the width of the line by clicking on the BorderWidth tab. If you want to change the style, do so in the BorderStyle property.
* Click on the shape control to add a shape on your form. The steps for making any shape are similar to those of making a line. Simply click on shape control and use your mouse to create a shape to add to the form. Rectangle is the default shape and its shape property is set to 0. If you want to make a square, set the shape property to 1. For an oval, set it to 2. Use 3 to make a circle and 4 to make a rounded rectangle. You can also alter the background color of the shape in the BackColor property tab. If you want to change the color of the shape’s border, alter the values in the BorderColor tag. The width can be adjusted in the BorderWidth property tab.
* If you want to add pictures to the form, go to the properties Window and click on picture property. Adding lines and shapes to your form can make it look interesting. However, to make the interface more attractive to the user, it is better to include pictures or images. Luckily, Visual Basic has graphic tools that you can use for this purpose: picture box and image box. To add an image or picture, just click on the Picture Property found at the window and wait for the dialog box to pop up. Select your desired picture file from any of the folders in your computer and the program will incorporate the picture into your form for you.


If you want to make any changes on the lines, shapes, and images that you have added, simple double-click on the object and adjust the properties on the tabs that you will see. You can also click on the Scribble icon in order to make the objects look like they have been drawn rather than pasted from image-editing software. Once you are done drawing, click on any other tool in order to exit the drawing module.

No comments:

Post a Comment