Print a Single Sub or Function

Need a fast way to print only one sub or function in VB3 that also takes care of the problem some printers have in printing the last page?Create a small form with one command button. Change the button’s Caption to Print Sub. Add this code to the button’s Click event:

 Sub Command1_Click ()	'Make sure VB has the focus.	AppActivate "Microsoft Visual Basic"	'Clear the Clipboard just in case.	Clipboard.Clear	'Select the Sub or Function and copy	'it to the Clipboard.	SendKeys "^{HOME}" & "^+{END}" & "%EC", True	'Print the Clipboard	Printer.Print Clipboard.GetText ()	'Form Feed in case printer needs it	'to print the last page.	Printer.NewPage	'End the print job.	Printer.EndDoc	'Unmark the Sub or Function.	SendKeys "{HOME}", TrueEnd Sub

Move the form to a spot you want it to appear in when running. Compile it to an EXE file. Run it along with Visual Basic. When you want to print a sub or function, make sure the cursor is in the Sub or Functions code box, and click on the Print Sub button.Printer.EndDoc called immediately after Printer.NewPage ensures that no blank page is printed.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS