DEPARTMENT OF TECHNICAL EDUCATION
ANDHRA PRADESH
Name : B. NARASIMHA MURTHY
Designation : Lecturer / CME
Branch : Computer Engineering
Institute : G I P D C E & T, Tirupati
Year/Semester : V Semester
Subject : Visual Basic Programming
Subject Code : CM / IT – 504
Topic : Graphics in Visual Basic
Duration : 50 Mts.
Sub Topic : Attributes of Crystal report screen
& Fundamentals of Printing, Printer
Object
Teaching Aids : Animation Clips and Images
CM504.49to50 1
Recap:
In the previous session, you have learnt about
• Format function, syntax and named formats
• Suitable VB Project using format function.
CM504.49to50 2
Objective :
On completion of this period, you would be able
to learn
• Attributes of Crystal report form.
• Fundamentals of printing.
• Printer object, its properties and methods.
CM504.49to50 3
Attributes of Crystal Report form:
Crystal report
VB supports crystal reports
•Provides an easy way to design reports.
•It’s a third party tool.
•You can design and test report graphically using
crystal reports.
•The report layout details are stored in a file with
rpt extension.
CM504.49to50 4
Attributes of the Crystal Report Screen.
The following are the attributes of the Crystal
Report Screen.
1. Report File Name: The file name of the
report to be printed.
2. Report Source: Choose to use a report file
or to get data from a data control.
CM504.49to50 5
Attributes of the Crystal Report Screen.
contd…
3. Selection Formula: A formula to be merged with
the current record selection formula in the
report.
4. SQL Query: Overrides SQL query string.
5. User Name: The user name used to open a
protected MS Access database.
6. Window Title: The title of the print window.
7. Connect: An ODBC connect string.
8. Data Source: The data control to report on.
9. Grid Source: The Grid to report on.
CM504.49to50 6
Fundamentals of Printing with VB:
• Printer object is used to print.
• We assign text and graphics to printer object.
• Printers collection is another object useful
printing.
• It holds an array of available printers.
CM504.49to50 7
The Printer Object:
• Visual Basic uses the default printer setup in
Control panel as the printer object.
• One way to print is the PrintForm command
• It sends a screen dump of a form to the printer.
• If your application has more than one form,
then you have to use the form name in this command:
FormName.PrintForm
• As this command does a bit-by-bit dump of the whole
form (including captions and borders), it lacks
flexibility.
CM504.49to50 8
The Printer Object:
Contd..
•The usual way to send information to a printer is
the Print method applied to the Printer object.
• As the Print method is page oriented, you can set
the CurrentX and CurrentY properties to
precisely position text or even dots on a page.
• The syntax used to send text to the printer is
similar to that used for Forms or picture
boxes:
Printer.Print TextToPrint.
CM504.49to50 9
The Printer Object:
Contd..
•Semicolons and commas also work the same
way they do for forms.
•The semicolon suppresses the automatic
carriage return/line feed combination;
•The comma moves to the next free print zone
(still 14 columns apart in the average character
width of the current font).
The Tab and Spc functions also work the
same
CM504.49to50 10
Properties and Methods for the Printer:
Here are some printer properties and methods you will use
most often.
ColorMode : This property lets you determine whether a color
printer prints in color or monochrome. The two
possibilities are shown in the following table.
Symbolic Constant Value Description
VbPRCMMonochrome 1 Prints output in monochrome
VbPRCMColor 2 Prints output in color
Table.1 CM504.49to50 11
Properties and Methods for the Printer:
Copies: This property lets you set the number of
copies to be printed.
Height, Width: These properties give you the
height and width of the paper in the printer as
reported by Windows. This is measured in twips,
regardless of how you set the scale properties.
EndDoc:This method tells Windows that a
document is finished. The syntax is
Printer.EndDoc
CM504.49to50 12
Properties and Methods for the Printer:
• This releases whatever information there
is about the page or pages still in memory
and sends it to the Windows Print
Manager for printing.
NewPage: This method ends the current
page and tells the printer to move to the
next page. The syntax is
Printer.NewPage
CM504.49to50 13
Page:
• keep tracks of number of pages.
•Page number start at 1.
•After page is printed the page number value is
incremented.
•Page increment Is terminated with END DOC
statement.
CM504.49to50 14
PrintQuality:
• Used to set the quality of printed out put.
• Quality is set using the following statement
Print.PrintQuality = Value
CM504.49to50 15
Any Questions …
CM504.49to50 16
Summary
In this class , you have learnt …
• Attributes of Crystal report form.
• Fundamentals of printing.
• Printer object, its properties and methods
CM504.49to50 17
Quiz
1. Which of the color mode property is useful for
color printing
a. Vb PRC monochrome
b. Vb color
c. Vb PRCM color
d. None
CM504.49to50 18
Quiz
1. Which of the color mode property is useful for
color printing
a. Vb PRC monochrome
b. Vb color
c. Vb PRCM color
d. None
CM504.49to50 19
Frequently Asked Questions
1. Explain the details of various ways of
printing in VB.
2. Describe in brief the various attributes of
crystal report screen.
3. What are printer objects.
4. Write about printing using printer object.
CM504.49to50 20