Vous êtes sur la page 1sur 50

DEPARTMENT OF TECHNICAL EDUCATION

ANDHRA PRADESH
Name : P. Sri Vidya
Designation : Lecturer
Branch : DCCP
Institute : Govt. Polytechnic for Women, Bheemili
Semester : VI Semester
Subject : Visual Basic II
Subject code : CCP- 603
Topic : Displaying and Printing
Information(4/10)
Sub Topic : Displaying tabular data in report form
Duration : 100 min.
CCP603.9 TO 10 1
Teaching Aids : PPT
Recap

 Displaying data in tabular form on screen


 Data Environment Designer
 Data Report Designer
 Creating a report using Data Report Designer

CCP603.9 TO 10 2
Objectives

On completion of this period, you would be able to:


 Know the fundamentals of printing
 Printer Object
 PrintForm method

CCP603.9 TO 10 3
KNOWN TO UNKNOWN

What is the command to print a document


or worksheet?
Print

CCP603.9 TO 10 4
Print command exists in which menu?

File

CCP603.9 TO 10 5
Techniques to print text and graphics in VB

 Print command
 Printer object
 PrintForm method

CCP603.9 TO 10 6
Print Command

What is the use of Print command in VB?


 Directs all the text and graphics from the VB
application to the default printer
 We can set the default printer to any one
member in the Printers Collection

CCP603.9 TO 10 7
Printers Collection Object

 It is an object that contains all the printers that are


available on the O.S,the same as those available in
the Print Setup dialog box or the Windows control
panel
 Each printer in the collection has a unique index
starting with 0 with which we can refer the printer
 Set Printer = printers(n)

CCP603.9 TO 10 8
Print Command in VB
 Click on File  Print

CCP603.9 TO 10 9
Options of Print dialog box
Printer -
 Identifies the printer to which we are printing
Range -
 Determines the range we print
 It may be entire project or current module or selected portion
Selection -
 Prints the currently selected code
Current module -
 Prints the forms and / or code for the currently selected
module

CCP603.9 TO 10 10
Current Project -
 Prints the forms and / or code for the entire
project
Print What -
 Determines what we print depending on what
we selected as the range
Form Image -
 Prints the form images
Code -
 Prints the code for the selected range

CCP603.9 TO 10 11
Print Quality -
 Determines whether to print
High

 Medium

 Low or

 Draft

Output quality

CCP603.9 TO 10 12
Print to File -
 Sends the print to file selected in the Print to
File dialog box.
OK -
 Prints the selection
Cancel -
 Closes the dialog box without printing

CCP603.9 TO 10 13
Setup -
 Displays the standard Print Setup dialog box

CCP603.9 TO 10 14
Options of Print Setup

Printer -
 Allows you to specify the printer. If you don't
select a printer, Visual Basic will print to the
Windows default printer
Name -
 Displays a list of available printers
Status -
 Displays the status of the printer and whether
it is ready to print
Type -
 Displays the type of printer
CCP603.9 TO 10 15
Options of Print Setup
Where -
 Displays the location of the printer. If the
printer is on a network, displays the path to the
server
Comment -
 Displays the physical location of the printer and
additional information
Properties -
 Opens the Properties dialog box specific to
the printer where you can choose additional
options such as paper and the way graphics
are printed
CCP603.9 TO 10 16
Options of Print Setup
Paper -
 Allows you to select the paper size and source
(from among those available for the printer)
 The sizes and sources available depend on the
printer you have selected and they change
when you change printers
Size -
 Displays a list of the available paper sizes
Source -
 Displays the available source of paper for the
printer you choose
CCP603.9 TO 10 17
Options of Print Setup

Orientation -
 Allows you to specify whether the program is
to print in Portrait or Landscape orientation.

CCP603.9 TO 10 18
Procedure to print text and graphics using
Print command.

 Click on File  Print


 Set the Range- Section or Module or Project
 Set the Print What option- Form Image, Code,
Form As Text
 Set the Print Quality- high, medium, low, draft
 Click on Setup
 Set the Printer, Paper Size, Orientation
 Click on Ok

CCP603.9 TO 10 19
Printer object

What is Printer object?


 The Printer object is a device-independent
drawing space that supports
 The Print, Pset, Line, Paint Picture and Circle
method to create text and graphics

CCP603.9 TO 10 20
What is the use of printer object?

 The printer object enables to communicate with a


system printer
 We can draw text and graphics on printer object
using graphics methods
 Once the printer object contains the output we
want to print, we can use EndDoc method to send
output directly to the printer

CCP603.9 TO 10 21
How can we draw text and graphics on
printer object?

 We can draw text and graphics on printer object


using graphics methods

CCP603.9 TO 10 22
What are graphics methods?

 Graphics methods are the methods that operate


on an object such as a form, picture box or printer

CCP603.9 TO 10 23
List of some graphics methods

 Circle
 Cls
 Line
 Paintpicture
 Point
 print
 Pset

CCP603.9 TO 10 24
How can we send output the printer ?

 Once the printer object contains output we want to


print, we can use the EndDoc method to send the
output directly to the default printer for the
application

CCP603.9 TO 10 25
Advantages of Printer object

The Printer object provides best quality across a


variety of printers because
 Windows translates text and graphics from the
device-independent drawing space of the Printer
object to best match the resolution and ability of
the printer

CCP603.9 TO 10 26
Drawbacks of Printer object

 Code is required to perform operations


 Printing bitmaps takes time and slow the
performance of application

CCP603.9 TO 10 27
Properties of Printer object

Color Mode property -


 Returns or sets a value that determines whether a
color printer prints output in colour or monochrome
Enter Setting Value Description
 VBPRGMMonochrome 1. Print output in
monochrome
 VBPRGMColor 2. Print output in color.

CCP603.9 TO 10 28
Copies Property

 Returns or sets a value that determines the


number of copies to be printed
 Printer.Copies = 1

CCP603.9 TO 10 29
Current X,Current Y property

 Returns or sets the horizontal(current X) or


vertical(current Y) co-ordinates for the next printing
Syntax: Object.CurrentX = X
Object.CurrentY = Y

CCP603.9 TO 10 30
Device Name property

 Returns the name of the device a driver supports


Syntax : Object.Device name

CCP603.9 TO 10 31
Draw mode property

 Returns or sets a value that determines the


appearance of output from graphics method or the
appearance of a shape or line control
 Syntax: Object. Draw mode[=number]
Vb blackness 1 Black

Vb not merge pen 2 Not merge pen

Vb mask not pen 3 Mask not pen


Vb not copy pen 4
CCP603.9 TO 10 Not copy pen 32
Draw style property

 Returns or sets a value that determines the line


style for output from graphics methods
Syntax: Object. Draw style [=number]
Vbsolid 0 (default) solid
Vbdash 1 Dash
Vbdot 2 Dot
Vbdashdot 3 Dash-Dot

CCP603.9 TO 10 33
Duplex property
 Returns or sets a value that determines whether a
page is printed on both slides

CCP603.9 TO 10 34
Methods of printer object

Enddoc method -
 Terminates a print operation sent to the printer
object,releasing the document to the print device
Syntax: Object. Enddoc

CCP603.9 TO 10 35
KillDoc Method -
 Immediately terminates the current print job
Syntax: Object.KillDoc

CCP603.9 TO 10 36
New page Method
 Ends the current page and advances to the next
page on the printer object
Syntax : Object.New page

CCP603.9 TO 10 37
Paint picture Method
 Draws the contents of a graphics file on printer
pset method
 Sets a point on an object to a specified color

CCP603.9 TO 10 38
PrintForm method

What is the use of PrintForm method?


 PrintForm method sends an image of the
specified form bit by bit to the printer
 It prints entire form even though it does not
appear on the fully on the screen

CCP603.9 TO 10 39
What items can be printed using PrintForm
method?

PrintForm method prints


 All visible objects and bitmaps of the Form
object
 Graphics added to a Form or Picture box at
runtime, if the AutoRedraw property is True
when the graphics are drawn
 Syntax : Form.PrintForm
PrintForm – prints the current form

CCP603.9 TO 10 40
Advantages of PrintForm method

 PrintForm method is the easiest way to print form


because it sends information to the printer at the
resolution of user’s screen- typically 96 dots per
inch

CCP603.9 TO 10 41
Disadvantages of PrintForm method

 Results may not be accurate with much higher


resolutions

CCP603.9 TO 10 42
QUIZ
1. Print command directs
a) Only text to the default printer
b) Only graphics to the default printer
c) Both text and graphics to the default printer
d) None of the above

CCP603.9 TO 10 43
1. The object that contains all the available printers
on the OS.
a) Print object
b) Printers collection
c) PrintForm method
d) Print method

CCP603.9 TO 10 44
3. Printer object is
a) Device independent drawing space
b) Device dependent drawing space
c) Not a drawing space
d) None of the above

CCP603.9 TO 10 45
4. Which method is used to send output directly to the

printer?
a) EndDoc method
b) KillDoc method
c) NewPage method
d) Paintpicture method

CCP603.9 TO 10 46
5. Which method is used to print a form bit-by-bit to
printer?

 PrintForm method

CCP603.9 TO 10 47
Frequently asked questions

1. What are the different methods to print information


in VB?
2. Discuss the Print command .
3. Explain the properties, methods events of Printer
object.
4. Write about PrintForm method.

CCP603.9 TO 10 48
Summary

 Text and graphics can be printed in VB using


a) Print command- device dependent
b) Printer Object- device independent
 Best quality output comes but code is required
 PrintForm method
 Easiest method to print forms

CCP603.9 TO 10 49
THANK YOU

CCP603.9 TO 10 50

Vous aimerez peut-être aussi