Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Apr 22, 1997

How to Send to the Printer

Question:
I am very new to Visual Basic and have just run this simple program:
For x = 1 to 10
Print x
Next x
End
This produces a list of numbers from 1 to 10. I would like to know how to print out this list. I have a HP Deskjet 693C printer.

Answer:
You're almost there...try this code:

   Dim i As Integer
   For i = 1 To 10
      Printer.Print i
   Next i
   Printer.EndDoc
All printer commands have to be sent using the Printer object. In addition, the EndDoc method of the Printer object tells the printer that the current document is done. If you want to make this code fancier, you can set the Font property of the Printer object to a new font, as shown here:
   Dim i As Integer

   Printer.Font.Name = "Times New Roman"
   Printer.Font.Size = 14
   Printer.Font.Italic = True

   For i = 1 To 10
      Printer.Print i
   Next i
   Printer.EndDoc
This will print your text in Times New Roman, 14 point italic text.
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date