devxlogo

How to Send to the Printer

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 10Print xNext xEnd
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 currentdocument 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-admin

Share the Post: