Click here to Skip to main content
15,181,193 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I have created a Form using VB and I can not get it to print.
I have loaded all the Print Things below the Form.
Tried different Codes and nothing works.
I can get it to go to the Printer, but just spits out a plain sheet.

What I have tried:

I have tried many suggested codes and still nothing.
I even had encounter code errors.
Posted
Updated 5-Oct-21 5:53am
Comments
Richard MacCutchan 5-Oct-21 10:07am
   
And you think maybe we can guess what you are doing?
Dave Kreskowiak 5-Oct-21 10:28am
   
...and the code you're using to try to print the form is ... ? A complete secret since you didn't post it here.

1 solution

We can't be specific: there are two ways to print in VB, the older VB6 compatible way using PrintForm Class (Microsoft.VisualBasic.PowerPacks.Printing) | Microsoft Docs[^] which literally prints the content of a form on paper, and the more modern and flexible PrintDocument Class (System.Drawing.Printing) | Microsoft Docs[^]

The former is easy to use - just follow the link - the latter requires more thought and effort (though there is a basic example in it's link) but provides a much more flexible and user-friendly result. Particularly if you succumb to the modern trent to "Dark Mode" where the PrintForm version will have your users organising lynch mobs ...

With a PrintDocument, you do all the work of deciding where exactly stuff goes and what gets printed on which page - but that's where the flexibility comes in: you decide, you implement, and the design of your user interface has nothing to do with the printout. It may seem a daunting way to do things, but it's pretty simple once you get your head around it.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900