How can I catalog, index and / or print the VB6 source code, with each sub / function on the page ..?

How can I catalog, index and / or print the VB6 source code with each sub or function on my page.? I would like to do this with the free or included Visual Studio add-ons, if possible, but I don't mind writing something myself. I am familiar with “Microsoft Visual Basic for Application Extensibility,” and it looks like VB6 has a similar module that can allow me to simply “for everyone” through a collection of code modules and drop subtitles to the printer one at a time. This will probably take 10-15 lines of code.

My first priority is printing, preferably with each sub / function on its own page, but with the usual IDE printing function, all the code works together in one long printout. Then after that, I would like to create an index / current of the names of each sub, function, variable and constant in each VBP. We have a version of Visual Studio 6.0 Enterprise Edition, but there seems to be nothing in it to do any of these things.

You can laugh and ask: "Why VB6 .. ?? LOL !!". This is because I was instructed to update and modify the source code of the VB6 large software system that launches the factory. This is on an isolated network without connecting to the outside world, and it has been working fine for 14 years, but now they want to start some improvements. The system consists of many VBP files, each of which has many modules and forms.

Edit: I tried Google to answer this, but that turned out to be impossible. All I got was a coded sample about printing from applications written in VB6, and not for printing source code from the IDE.

+7
visual-studio vb6 visual-studio-6 vbide
source share
4 answers

You do not need to parse the code correctly to meet your requirements. Write something. You can print to a printer or to HTML files. I did it once, it worked fine.

Source code files are just text files. Read the files line by line, print each line. Start a new page every time you see "end sub" or "end function" or "end property". Thus, each method runs on a separate page. FRM files have control definitions at the top, you can skip this by simply looking for a line containing only the "end". The code starts there.

If you do a lot of VB6, I also recommend getting a brilliant addition to MZ Tools . It has excellent search tools. Unfortunately, it is no longer free, but IMHO costs money. I have no contact with the seller.

+2
source share

Write an add-in. This is much simpler than you might suspect.

Get the book, “Developing Visual Basic Add-Ins,” by Stephen Roman (O'Really, 1999, ISBN 1-56592-527-0).

+1
source share

Parsing a module for procedures and functions is difficult, believe me . In particular, with the continuation of the line as follows:

_ Public _ Sub _ Foo() ' _ End Sub _ End _ _ Sub _ 

In addition, a property can be completed using End Property , but also with End Function or End Sub

Fortunately, VBIDE for VB6 has more classes and methods for working with VB projects than the VBA VBIDE version.

One of them is the CodePane.Members property, which returns a collection of all identifiers (although, I think, it omits the Type and Enum identifiers, but they are still declared in the module declaration section) in the module.

enter image description here

And each member provides various properties, including its location in the module: enter image description here

If you are interested in analyzing a more detailed and fully functional add-in for the IDE, you should take a look at Rubberduck -VBA on GitHub (I am the author). It currently works with VBA hosts, but VB6 is on the roadmap. It has one of the most reliable VB parsers and is available with open source.

+1
source share

You can use a code search tool that indexes langauge elements for quick searching and searching. This will simplify the search for the code of interest and will not even print all this paper, because instead, you just look at the code.

Our source code search system knows the lexical elements of many languages, in particular, VB6. It reads the source code base (thousands of files) and builds an index that helps you quickly find code elements. Using your graphical interface, you can write queries in terms of language elements to search for code fragments, such as:

  S=*Login* 

find strings (only) containing the text "Input" (using simple WildCards) or

  'SUB' I=/[Aa]ccount.*/ 

which will find all routines whose name begins with "account", regardless of the first letter (full regular expression) or

  'IF' ... N>17<35 

Find IF expressions that use any value from 17 to 35 (".." means "next to"). The query element N allows you to quickly and easily find a constant.

A really powerful feature of the query language is "not". This allows you to build a sloppy query that finds "too much" and then eliminates "too much":

  I '+' I - I=xyz 

finds two added variables that do not include the xyz variable.

You can click any of the hit lists, and the code text will appear in the GUI window. No need for paper.

Since he knows the lexical structure of each langauge, he is not confused by spaces, lines, comments, or even lines containing code that looks like text.

0
source share

All Articles