Tip

Printing 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, http://www.johnsmiley.com/smass/smass.htm a computer consulting firm located in New Jersey.

This was first published in July 2000

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.