SlideShare a Scribd company logo
1 of 16
Visual Basic
Lines and Shapes
2
Objectives
 Explain the coordinate system used to
position graphical objects on a form.
 Draw lines from code.
 Draw boxes and rectangles from code.
 Draw circles and ellipses from code.
3
Objectives (continued)
 Draw polygrams.
 Create images made up of multiple
objects drawn on a form.
4
Drawing Objects Using Code
 Visual Basic .NET provides a single
Graphic object with a large number of
methods that allow a program to draw
on a form.
 A Graphics object is a general-purpose
drawing surface that may be used with
a number of graphical tools in Visual
Studio .NET.
5
Understanding Coordinates
 In order to begin working with drawing
objects, you must first understand the
coordinate system on a form.
 The top-left point on a form has an X
coordinate of zero and a Y coordinate of
zero.
 To use the DrawLine method, you need to think
in terms of X and Y rather than top and left.
 The combination of the X and Y value is
called a Point.
6
Understanding Pens and
Brushes
 After specifying the location of an
object, you will also have to specify a
Pen or Brush to use to draw the object.
 A pen is used to draw lines or the outline
of a shape.
 A brush is used to fill in shapes or to draw
text.
7
Using the DrawLine Method
 To use the DrawLine method, you
must specify the endpoints of the line
you want to draw and the pen you
want to use to draw the line.
 You can also create a Pen inside the
DrawLine statement.
8
Drawing Rectangles and
Boxes
 Rectangles and boxes can be drawn in two
different ways:
 The DrawRectangle method uses a Pen object
and is used to draw the outline of a rectangle.
 The FillRectangle method uses a Brush object
and is used to draw a rectangle that is filled in.
 The rectangle is created with an X and Y
location for its top-left corner and two other
parameters that will specify the width and
height properties.
9
Drawing Circles and Ellipses
 Like rectangles, circles and ellipses can
either be drawn as outlines or as filled
objects.
 The parameters for the DrawEllipse method
are a Pen object, the location of the ellipse,
and the width and height of the ellipse.
 The FillEllipse method uses the same
location and size parameters, but uses a
Brush object in place of a Pen object.
10
Drawing Polygons
 A polygon is any shape with three or
more sides.
 The DrawPolygon method takes a Pen
as its first parameter.
 The second parameter is an array of
points.
 The array has one element less than
the number of sides in the polygon.
11
Locating the Mouse
 The MouseDown event returns a number of
useful pieces of information.
 It returns the location on the form where the
mouse was pointing when the mouse button was
pressed.
 This variable, ”e,” has an X and Y coordinate
and holds the location where the mouse was
clicked.
 This will allow your program to draw
wherever the user wishes to draw.
12
Clearing the Form
 The form can be cleared in two ways:
 Parts of the form may be cleared by
drawing new shapes over existing
shapes.
 Another way is to use the Clear method
of the Graphics objects.
13
Summary
 You can use the DrawLine method to draw a
line on a form using Visual Basic. NET code.
 There are two ways to draw most shapes
on a form. A Draw method creates an outline
drawing of the object. The Fill method
creates an object that is filled with a color
specified by a brush color.
 A Pen object is created with a color and may
also have a line specified for it.
14
Summary (continued)
 Rectangles (including squares) are created
using the DrawRectangle and FillRectangle
methods. Rectangles are objects that can
be declared with a starting point and width
and height. Once they are declared,
rectangle objects can be used to draw both
rectangles and ellipses.
 Ellipses (including circles) are created using
the DrawEllipse and FillEllipse methods.
15
Summary (continued)
 Once you have drawn a line, rectangle,
ellipse, or other shape with a graphic
method, you cannot manipulate it. The
graphic methods draw directly on a form.
 The MouseDown event returns information
about the location of the mouse and the
button that was used to click on the mouse.
 The Clear method of the Graphics object is
used to erase the whole form.
16
Summary (continued)
 Distance and position on a form is mea-
sured using coordinates. The top-left corner
of a form has the coordinates (0, 0). All
coordinates are positive. As you move
toward the bottom of a form, the X-coordi-
nate value increases. As you move toward
the right of a form, the Y-coordinate value
increases.

More Related Content

What's hot

Plan601 e session 4 demo
Plan601 e session 4 demoPlan601 e session 4 demo
Plan601 e session 4 demo
rkottam
 
G6 m3-c-lesson 17-s
G6 m3-c-lesson 17-sG6 m3-c-lesson 17-s
G6 m3-c-lesson 17-s
mlabuski
 
Dm week01 linreg.handout
Dm week01 linreg.handoutDm week01 linreg.handout
Dm week01 linreg.handout
okeee
 
Inequalties Of Combined Functions2[1]
Inequalties Of Combined Functions2[1]Inequalties Of Combined Functions2[1]
Inequalties Of Combined Functions2[1]
guestf0cee6
 
Algebra 1, 5 3
Algebra 1, 5 3Algebra 1, 5 3
Algebra 1, 5 3
Wood-Ridge
 
1291 fa13 assign6_folded_model_paneling
1291 fa13 assign6_folded_model_paneling1291 fa13 assign6_folded_model_paneling
1291 fa13 assign6_folded_model_paneling
NYCCTfab
 
Inequalties Of Combined Functions2[1]
Inequalties Of Combined Functions2[1]Inequalties Of Combined Functions2[1]
Inequalties Of Combined Functions2[1]
guestf0cee6
 
Task 3 geometry
Task 3 geometryTask 3 geometry
Task 3 geometry
Rexeh1245
 

What's hot (19)

Obj. 50 3-D Representation
Obj. 50 3-D RepresentationObj. 50 3-D Representation
Obj. 50 3-D Representation
 
Geogebra
GeogebraGeogebra
Geogebra
 
Excel-bar-graph
Excel-bar-graphExcel-bar-graph
Excel-bar-graph
 
L1 slides
L1 slidesL1 slides
L1 slides
 
Geogebra 9
Geogebra 9Geogebra 9
Geogebra 9
 
Plan601 e session 4 demo
Plan601 e session 4 demoPlan601 e session 4 demo
Plan601 e session 4 demo
 
G6 m3-c-lesson 17-s
G6 m3-c-lesson 17-sG6 m3-c-lesson 17-s
G6 m3-c-lesson 17-s
 
Dm week01 linreg.handout
Dm week01 linreg.handoutDm week01 linreg.handout
Dm week01 linreg.handout
 
Inequalties Of Combined Functions2[1]
Inequalties Of Combined Functions2[1]Inequalties Of Combined Functions2[1]
Inequalties Of Combined Functions2[1]
 
GeoGebra Talk - A basic introduction
GeoGebra Talk - A basic introductionGeoGebra Talk - A basic introduction
GeoGebra Talk - A basic introduction
 
Efficient Estimation for High Similarities using Odd Sketches
Efficient Estimation for High Similarities using Odd Sketches Efficient Estimation for High Similarities using Odd Sketches
Efficient Estimation for High Similarities using Odd Sketches
 
Geogebra 8
Geogebra 8Geogebra 8
Geogebra 8
 
Cap.7
Cap.7Cap.7
Cap.7
 
Algebra 1, 5 3
Algebra 1, 5 3Algebra 1, 5 3
Algebra 1, 5 3
 
Plan601 e session 1 demo 20151005
Plan601 e session 1 demo 20151005Plan601 e session 1 demo 20151005
Plan601 e session 1 demo 20151005
 
computer graphics-C/C++-dancingdollcode
computer graphics-C/C++-dancingdollcodecomputer graphics-C/C++-dancingdollcode
computer graphics-C/C++-dancingdollcode
 
1291 fa13 assign6_folded_model_paneling
1291 fa13 assign6_folded_model_paneling1291 fa13 assign6_folded_model_paneling
1291 fa13 assign6_folded_model_paneling
 
Inequalties Of Combined Functions2[1]
Inequalties Of Combined Functions2[1]Inequalties Of Combined Functions2[1]
Inequalties Of Combined Functions2[1]
 
Task 3 geometry
Task 3 geometryTask 3 geometry
Task 3 geometry
 

Similar to VB Lines and Shapes

Plan601 e session 2 demo
Plan601 e session 2 demoPlan601 e session 2 demo
Plan601 e session 2 demo
rkottam
 
Plan601 e session 2 demo
Plan601 e session 2 demoPlan601 e session 2 demo
Plan601 e session 2 demo
rkottamasu
 
PLAN601E SESSION 2 DEMO
PLAN601E SESSION 2 DEMOPLAN601E SESSION 2 DEMO
PLAN601E SESSION 2 DEMO
rkottam
 
Plan601 e session 2 demo sp14
Plan601 e session 2 demo sp14Plan601 e session 2 demo sp14
Plan601 e session 2 demo sp14
rkottam
 
Plan601 e session 2 demo
Plan601 e session 2 demoPlan601 e session 2 demo
Plan601 e session 2 demo
rkottamasu
 
Plan601 e session 2 demob
Plan601 e session 2 demobPlan601 e session 2 demob
Plan601 e session 2 demob
rkottam
 
AutoCAD Lines with Instruction
AutoCAD Lines with InstructionAutoCAD Lines with Instruction
AutoCAD Lines with Instruction
KierShare
 
plan601 e session 2 demo
plan601 e session 2 demoplan601 e session 2 demo
plan601 e session 2 demo
rkottam
 

Similar to VB Lines and Shapes (20)

Unit 1- Introduction.pptx
Unit 1- Introduction.pptxUnit 1- Introduction.pptx
Unit 1- Introduction.pptx
 
Introduction to CorelDRAW
Introduction to CorelDRAWIntroduction to CorelDRAW
Introduction to CorelDRAW
 
Plan601 e session 2 demo
Plan601 e session 2 demoPlan601 e session 2 demo
Plan601 e session 2 demo
 
VECTOR.pptx
VECTOR.pptxVECTOR.pptx
VECTOR.pptx
 
Plan601 e session 2 demo
Plan601 e session 2 demoPlan601 e session 2 demo
Plan601 e session 2 demo
 
PLAN601E SESSION 2 DEMO
PLAN601E SESSION 2 DEMOPLAN601E SESSION 2 DEMO
PLAN601E SESSION 2 DEMO
 
Plan601 e session 2 demo sp14
Plan601 e session 2 demo sp14Plan601 e session 2 demo sp14
Plan601 e session 2 demo sp14
 
Plan601 e session 2 demo
Plan601 e session 2 demoPlan601 e session 2 demo
Plan601 e session 2 demo
 
Plan601 e session 2 demob
Plan601 e session 2 demobPlan601 e session 2 demob
Plan601 e session 2 demob
 
AutoCAD Lines with Instruction
AutoCAD Lines with InstructionAutoCAD Lines with Instruction
AutoCAD Lines with Instruction
 
plan601 e session 2 demo
plan601 e session 2 demoplan601 e session 2 demo
plan601 e session 2 demo
 
Corel Draw final presentation for software.pptx
Corel Draw final presentation for software.pptxCorel Draw final presentation for software.pptx
Corel Draw final presentation for software.pptx
 
Adobe illustrator cs4 tutorial
Adobe illustrator cs4 tutorial Adobe illustrator cs4 tutorial
Adobe illustrator cs4 tutorial
 
Auto cad manual
Auto cad manualAuto cad manual
Auto cad manual
 
Chapter 13
Chapter 13Chapter 13
Chapter 13
 
Introduction to Animation - NOLA Mini Maker Faire
Introduction to Animation - NOLA Mini Maker FaireIntroduction to Animation - NOLA Mini Maker Faire
Introduction to Animation - NOLA Mini Maker Faire
 
Inkscape - A brief
Inkscape - A briefInkscape - A brief
Inkscape - A brief
 
Presentation 12
Presentation   12Presentation   12
Presentation 12
 
Plan601 e session 2 demo
Plan601 e session 2 demoPlan601 e session 2 demo
Plan601 e session 2 demo
 
Adobe illustrator cs6
Adobe illustrator cs6Adobe illustrator cs6
Adobe illustrator cs6
 

More from obrienduke (9)

VB Multiple Forms
VB Multiple FormsVB Multiple Forms
VB Multiple Forms
 
Graphics
GraphicsGraphics
Graphics
 
M14 overview
M14 overviewM14 overview
M14 overview
 
Mod 12
Mod 12Mod 12
Mod 12
 
Module 7
Module 7Module 7
Module 7
 
Unit 4 bugs and debugging
Unit 4 bugs and debuggingUnit 4 bugs and debugging
Unit 4 bugs and debugging
 
Module 3 GUI Design
Module 3 GUI DesignModule 3 GUI Design
Module 3 GUI Design
 
Arrays in java
Arrays in javaArrays in java
Arrays in java
 
Nested loops
Nested loopsNested loops
Nested loops
 

Recently uploaded

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Recently uploaded (20)

Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 

VB Lines and Shapes

  • 2. 2 Objectives  Explain the coordinate system used to position graphical objects on a form.  Draw lines from code.  Draw boxes and rectangles from code.  Draw circles and ellipses from code.
  • 3. 3 Objectives (continued)  Draw polygrams.  Create images made up of multiple objects drawn on a form.
  • 4. 4 Drawing Objects Using Code  Visual Basic .NET provides a single Graphic object with a large number of methods that allow a program to draw on a form.  A Graphics object is a general-purpose drawing surface that may be used with a number of graphical tools in Visual Studio .NET.
  • 5. 5 Understanding Coordinates  In order to begin working with drawing objects, you must first understand the coordinate system on a form.  The top-left point on a form has an X coordinate of zero and a Y coordinate of zero.  To use the DrawLine method, you need to think in terms of X and Y rather than top and left.  The combination of the X and Y value is called a Point.
  • 6. 6 Understanding Pens and Brushes  After specifying the location of an object, you will also have to specify a Pen or Brush to use to draw the object.  A pen is used to draw lines or the outline of a shape.  A brush is used to fill in shapes or to draw text.
  • 7. 7 Using the DrawLine Method  To use the DrawLine method, you must specify the endpoints of the line you want to draw and the pen you want to use to draw the line.  You can also create a Pen inside the DrawLine statement.
  • 8. 8 Drawing Rectangles and Boxes  Rectangles and boxes can be drawn in two different ways:  The DrawRectangle method uses a Pen object and is used to draw the outline of a rectangle.  The FillRectangle method uses a Brush object and is used to draw a rectangle that is filled in.  The rectangle is created with an X and Y location for its top-left corner and two other parameters that will specify the width and height properties.
  • 9. 9 Drawing Circles and Ellipses  Like rectangles, circles and ellipses can either be drawn as outlines or as filled objects.  The parameters for the DrawEllipse method are a Pen object, the location of the ellipse, and the width and height of the ellipse.  The FillEllipse method uses the same location and size parameters, but uses a Brush object in place of a Pen object.
  • 10. 10 Drawing Polygons  A polygon is any shape with three or more sides.  The DrawPolygon method takes a Pen as its first parameter.  The second parameter is an array of points.  The array has one element less than the number of sides in the polygon.
  • 11. 11 Locating the Mouse  The MouseDown event returns a number of useful pieces of information.  It returns the location on the form where the mouse was pointing when the mouse button was pressed.  This variable, ”e,” has an X and Y coordinate and holds the location where the mouse was clicked.  This will allow your program to draw wherever the user wishes to draw.
  • 12. 12 Clearing the Form  The form can be cleared in two ways:  Parts of the form may be cleared by drawing new shapes over existing shapes.  Another way is to use the Clear method of the Graphics objects.
  • 13. 13 Summary  You can use the DrawLine method to draw a line on a form using Visual Basic. NET code.  There are two ways to draw most shapes on a form. A Draw method creates an outline drawing of the object. The Fill method creates an object that is filled with a color specified by a brush color.  A Pen object is created with a color and may also have a line specified for it.
  • 14. 14 Summary (continued)  Rectangles (including squares) are created using the DrawRectangle and FillRectangle methods. Rectangles are objects that can be declared with a starting point and width and height. Once they are declared, rectangle objects can be used to draw both rectangles and ellipses.  Ellipses (including circles) are created using the DrawEllipse and FillEllipse methods.
  • 15. 15 Summary (continued)  Once you have drawn a line, rectangle, ellipse, or other shape with a graphic method, you cannot manipulate it. The graphic methods draw directly on a form.  The MouseDown event returns information about the location of the mouse and the button that was used to click on the mouse.  The Clear method of the Graphics object is used to erase the whole form.
  • 16. 16 Summary (continued)  Distance and position on a form is mea- sured using coordinates. The top-left corner of a form has the coordinates (0, 0). All coordinates are positive. As you move toward the bottom of a form, the X-coordi- nate value increases. As you move toward the right of a form, the Y-coordinate value increases.