Sie sind auf Seite 1von 21

DEPARTMENT OF TECHNICAL EDUCATION

ANDHRA PRADESH
Name : M.H.Prasad Rao
Designation : HCCP
Branch : D.C.C.P.
Institute : SGM G.P.T., Abdullapurmet
Year/Semester : V Semester
Subject : VISUAL BASIC-I
Subject Code : CCP-503
Topic : MDI Applications and Graphics
Duration : 50 Mts
Sub-Topic : Graphics - Lines
Teaching Aids used : PPT, Animations, Window
outputs

CCP503.53 1
OBJECTIVES
After completion of this class, you would
be able to:
 Know what is a line

 Different ways of drawing lines

 Using Line control to draw lines

 Line control’s properties

 Changing Line’s direction

CCP503.53 2
Know what is a Line

Definition:
 A Line is a line that connects two points on a plane.
 Each point is represented by its coordinate values.

CCP503.53 3
Know what is a Line
Shows a line joining two points whose coordinates
are shown in the PIcture

Fig:1

CCP503.53 4
Different ways of drawing lines

Lines can be drawn on a form:


 by a Line Control available in Tool Box

 by the Line() method of the Form

CCP503.53 5
Using Line Control to draw lines
on form
 Identifying Line Control

 Selecting the Line control

 Drawing it on the form to get a line

Fig:2

CCP503.53 6
Line Control’s Properties
 Understand the line’s properties

 Change line’s properties such as

 Border color

 Border style

 Border width

 Addresses of the points which the line


joins

CCP503.53 7
Changing Line’s direction
Line’s direction can be changed:
 with mouse.
 by changing coordinate values of its end points
in property sheet or programmatically during run
time

Fig:3 CCP503.53 8
Changing Line’s color

Explanation:
 Bordercolor property helps in changing
line’s color

Fig:4

CCP503.53 9
 By setting Bordercolor property to any of the
following named constants of colors or by a
hex number
vbRed, vbGreen, vbBlue, vbMagenta,
vbwhite etc.

CCP503.53 10
Changing Line style

Explanation:
 Borderstyle property helps in changing line’s style

Fig:5

CCP503.53 11
 By setting Borderstyle property to any of the
values shown in the property sheet above
such as 0,1, 2 etc.

CCP503.53 12
Changing Line’s width
Explanation:
 Borderwidth property helps in changing line’s
width

Fig:6

CCP503.53 13
 By setting Borderwidth property to any
integer value not exceeding form’s height

CCP503.53 14
Changing Line’s position on form
at design time
Explanation:
 Line’s position can be changed by changing
values of line’s x1,y1,x2,y2 properties which
represent coordinates of its end points

Fig:7
CCP503.53 15
Changing Line’s position on form
at Run Time
Explanation:
 Line’s position can be changed at runtime by
changing values of line’s x1, y1, x2, y2
properties which represent coordinates of its
end points as shown below:

CCP503.53 16
Changing Line’s position on form
at Run Time

 x1=inputbox(“give x1 value”)

y1=inputbox(“give y1 value”)

x2=inputbox(“give x2 value”)

y2=inputbox(“givey21 value”)

form1.line (x1,y1)-(x2,y2), vbRed

Fig:8

CCP503.53 17
Summary
We have discussed about
 What is a line?

 Ways of drawing lines

 Using line’s control

 Line control’s properties and changing


them at design and run time

CCP503.53 18
Quiz – Objective Type
1. A Line joins _______points
Two on a form
• A Line can have _________________number
Seven of
Borderstyles
• A Line’s width can be changed________________
True

• There are _____


Two different ways of drawing lines in VB
• A line’s direction cannot be changed __________
False

• A line requires _______number


Four of coordinates.

CCP503.53 19
Quiz – Objective Type
3. A Line’s width should be ______ value
a) Single
b) String
c) Integer
d) control

4. To draw 3 lines you need___line controls


a) 1
b) 3
c) 4
d) 6

CCP503.53 20
Frequently Asked Question
1. Explain the Line control in VB.

CCP503.53 21

Das könnte Ihnen auch gefallen