Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Visual Basic >> Snippet

19 Printing


'VB allows printing to 3 objects within a program
'1. Printer
'2. Picture controls
'3. Forms

Printer. Print "hello"
picture1. Print "hello"
form1. Print "hello"

'printer/picture/forms support key properties which affect where the printing
'takes place and how it look
.CurrentX   'starting X position
.CurrentY   'starting Y position
.ScaleMode   'values are twips, points, pixels, inches, cm, mm, character
.ScaleLeft   'coordinate at left of object
.ScaleTop   'coordinate at top of object
.ScaleWidth   'width of object
.ScaleHeight  'height of object

'Printing starts at x,y coordinates 0,0, or whereever set with .CurrentX and .CurrentY properties
Printer.CurrentX = 1000
Printer.CurrentY = 3000 

'Exact set of properties available depends on the printer driver supplied by the printer manufacturer

'To end printing on a page and start a new page use (does not apply to forms/pictures)
Printer.NewPage

'To end printing on a document and eject the page use (does not apply to forms/pictures)
'VB automatically calls this when a program ends, if there is content in the print buffer
Printer.EndDoc

'VB supples a special method to print  the entire content of a form
form1.printform

'When within the IDE, printing can also be in these two locations, but with no positioning control
'Debug window
'Immediate window