by Robin Thomas Benjamin McKay (10 Submissions)
Category: VB function enhancement
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (5 Votes)
The purpose of this article is to introduce the new user to the art of printing quickly and simply.
Many people believe VB to be a major pain as like other programming languages because they are too tech. So are most things if you think about it for long enough and you're new to it. Anyway, here is a simple way to print in visual basic and also introduce you to a neat printing method. I take no credit for this because it is an article I found elsewhere.
Create a new standard.exe
create two labels
do what you want with the labels. The name and the captions don't matter.
Now, create a button and change its caption to: &Print and its name to cmdPrint.
In the button's code window, type the following code:
Printer.Print label1.caption; spc(30); label2.caption
The above code must all be on 1 line.
Good. You've mastered a simple printing method.
You can, of course, manipulate the printing methods above to print documents in a snazzy manner.
Before End Sub, type the following code:
Printer.Enddoc
This ensures the print job ends as you finish printing. Nice one!