VB6 Tutorial 30: Lines and Shapes

By | 2018-04-15

Line and shape are the simplest controls in Visual Basic 6 IDE that do not raise events. They are only used for designing the program interface.

You can enhance the graphical user interface (GUI) of your application using these two controls. The knowledge of using them appropriately will greatly improve your software. You can easily learn about the properties of Lines and shape. Just experiment!

The Line control

Line is used to draw lines.

Some properties of the Line control are:

  • BorderColor: The BorderColor property sets the Line color.
  • BorderStyle: The BorderStyle property sets the style of the line like solid, dash, dot and other styles.
  • BorderWidth: The BorderWidth property sets the line width.
  • DrawMode: The DrawMode property has several symbolic constant values or named constant values that determine the appearance of the line control.

The Line method

You can even draw a line from your code. The Line method does the job.Line (x1, y1)-(x2, y2), color

Example

This example draws a line of 5 twips width.

DrawWidth = 5
Line (0, 0)-(500, 600), vbRed

You need to type the minus (“-“) sign between the two points.

Shape

Shape is used to draw different kinds of shapes. The shapes that you can draw using this control are rectangle, square, oval, circle, rounded rectangle and rounded square.

Shape control also has the same properties as the Line control plus some other simple properties such as BackColor that sets the background color, FillStyle that sets the filling style of the shape and FillColor that sets the color filling the shape.

Different shapes can be drawn from the code using some methods which are out of the scope of this lesson. They will be discussed later.

See the attached sample program for an example of how you can use it this control on your form.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.