How to Send to the Printer

How to Send to the Printer

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.

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.

See also  Comparing different methods of testing your Infrastructure-as-Code

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist