How can I catalog, index, and/or print VB6 source code with each sub or function on its own page..? I would like to do so with free or included Visual Studio Add-Ins if possible, but I'm not adverse to writing something myself. I'm familiar with "Microsoft Office Visual Basic for Applications Extensibility", and it seems that VB6 has a similar module, which may allow me to simply "For Each" through the code module collection and throw the subs at the printer one at a time. It would take maybe 10-15 lines of code.
My first priority is the printing, preferably with each sub/function on its own page, but with the normal print function of the IDE, all the code runs together in one long printout. Next after that, I would like to create an index/toc of the names of every sub, function, variable, and constant in each VBP. We have the Visual Studio 6.0 Enterprise Edition, but there does not seem to be anything in it to do any of these kinds of things.
You may laugh and ask, "Why VB6..?? LOL!!". It's because I've been tasked with upgrades and changes to VB6 source code of a large software system that runs a factory. It's on an isolated network with no connection to the outside world, and it's been running fine for 14 years, but now they want to start upgrading some things. The system is composed of many VBP files, each with many modules and forms.
Edit: I did try Googling for answers to this, but that proved impossible. All I got was coded samples about printing from apps written in VB6, not printing the source code from the IDE.
Parsing the module for procedures and functions is hard, believe me. Particularly with line continuations like this:
Furthermore, a Property can be ended with
End Property
, but also withEnd Function
orEnd Sub
Fortunately, the VBIDE for VB6 has more classes and methods for working with VB projects than the VBA version of VBIDE.
One of those is the
CodePane.Members
property that returns a collection of all of the identifiers (although, I think it omitsType
andEnum
identifiers, but they're declared in the declarations section of a module anyway) in a module.And each member exposes various properties including it's location in the module:
If you're interested in parsing in more detail, and in a fully-featured add-in for the IDE, you should take a look at Rubberduck-VBA on GitHub (I'm a contributor). It's currently working with VBA hosts, but VB6 is on the road-map. It has one of the most robust VB parsers available, and it's open-source.