Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

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



Application Security Testing: An Integral Part of DevOps

How to Send to the Printer

I am very new to Visual Basic and have just run this simple program:
For x = 1 to 10
Print x
Next x
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
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
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.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date