Problem solve Get help with specific problems with your technologies, process and projects.

Printing project contents to a VB file

This tip demonstrates how to print project contents to a VB file.

Printing project contents to a VB file 

I recently received an email from a reader who wanted to print the contents of his Visual Basic project to a file.

For those of you not familiar with this Print feature of Visual Basic, you can print an image of any or all of the forms in your Visual Basic project, plus the code in those forms, to a printer for documentation purposes.

In addition to printing directly to a printer, you can also route the print to a text file -- either for archive purposes or for subsequent printing.

The problem is that when my reader tried to view the output file using his Notepad Editor, he reported seeing strange characters at the top of the document, and when he printed the file from within Notepad, the results were far from satisfactory.

What causes this is that when he directed the print output to a file, his Windows default printer was set to a high tech model (either a laser or an ink jet printer). The strange characters included in the document were printer control characters that Windows inserted into the file -- the same characters that Windows would have sent to the default printer to ensure that the document printed properly...

Fortunately, the fix is easy.

To produce a file that can then be opened cleanly in an editor such as Notepad, you must first install a Generic-Text Only Printer driver on your system. You can do this by adding a Generic-Text Only Printer via the Windows Print Manager, and then selecting this Printer as the target printer in the VB Printer Dialog Box.

The result is that your output file will contain only text -- no special Printer Control Characters.

Written by John Smiley, MCP, MCSD and MCT, author, and adjunct professor of Computer Science at Penn State University in Abington, Philadelphia University, and Holy Family College. John has been teaching computer programming for nearly 20 years.

John Smiley is president of Smiley and Associates, a computer consulting firm located in New Jersey.

Dig Deeper on Win Development Resources

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.