Search Tools Links Login

VB6 Tutorial 30: Lines and Shapes


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:

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.

About this post

Posted: 2018-04-15
By: vb6boy
Viewed: 4,188 times

Categories

Visual Basic 6

VB6 Tutorial

Attachments

Line_and_Shape.zip
Posted: 4/15/2018 5:55:26 AM
Size: 1,379 bytes


Loading Comments ...

Comments

AnonymousCoward posted this comment on 2020-05-04:

Really happy to see VB6 guys still keeping it alive. Although I use C# and some time Java, yet prefered to keep VB6 old system with new ERPs in VB.Net. God bless you ..keep it up. 

You must be logged in to make a comment.