Print A Single Sub Or Function

Print A Single Sub Or Function

The problem? You want to print a single sub but VB always prints allthe subs that are in the current form. You could copy it to the clipboardand print it with the MS-Editor or Notepad. You could buy expensive toolsto do this seemingly simple task. Here’s a less annoying solution to theproblem. Generate a small form. Add a command button. The caption may be”Print Sub.” Then, add this code to the module:

 Sub Command1_Click ()	' Make sure that VB has the focus	AppAcitvate "Microsoft Visual Basic"	' Move the cursor to the upper left corner. 	' The sub can contain a maximum of 500 lines.	' send SHIFT together with the DOWN key 	' to mark the whole sub.SendKeys "{Home}{UP 500} + ({DOWN 500}) % (EC)", True 	' Copy SUB to the clipboardPrinter.Print Clipboard.GetText()	' Print ClipboardPrinter.EndDoc	' Un-mark the SUBSendKeys "{HOME}"End Sub

Generate the EXE and run it together with VB. Move the Print-Sub formto a convenient desktop position. If you want a single sub of your project to be printed, set the cursorto any position in this SUB and click on the Print-Sub button. I’ve tested the code with VB3 Pro. In other VB Versions (such as theGerman Standard edition) you might have to change the “%(EC)”portion. “EC” refers to the VB menu bar.

Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved