Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Aug 6, 1997

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}", True
End 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.
Kenneth L.
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date