Ok, there's a fairly good Windows "built-in" option for this, discussed here.
(Don't forget the Add-In companion for this program, found here.)
However, I wanted a more pure VB6 solution. So, I came up with the following. Basically, it just gives you a DebugPrint procedure in any program you're developing, with the output being persistent across exits and re-loads of the VB6 IDE. Also, if you're developing something that's crashing your IDE, it will be persistent for that as well. Also, it can show you substantially more volume of information than the IDE's Immediate window. Also, it will work from a compiled program as well as from the IDE.
It preserves the ability to use the comma (but not the semicolon) when printing debug information. For instance, the following are valid:
DebugPrint "Test Point #1"
DebugPrint "Var1:", Var1, "Var2:", Var2
But this won't work:
DebugPrint "Var1: "; Var1
With respect to the actual PersistentDebugPrint program, you can either compile it and execute it, or you can just execute it from the IDE. It'll work either way.
To use it, you just throw the DebugPrint.bas module into the program you're developing, and start making calls to the DebugPrint procedure.
Warning: In the PersistentDebugPrint program, I store a handful of settings in the registry. If you look, it's obvious what I'm storing, but I know that this concerns some people, so this is just a heads-up that I'm doing this.
Basically, here's all it is (from the Test program):
Enjoy,
Elroy
Update #1: The class name for the DebugPrint window is a bit different when compiled versus running in the IDE, and I forgot to check for that. That's now fixed. I also added a DoDebugPrint constant to the DebugPrint.bas module so you can turn it all on/off without needing to comment out your DebugPrint lines.
Update #2: I've actually tweaked on this thing quite a bit since I last updated it. Changes (I can remember):
There's now a "CodeForDebugPrint--->ToClipboard" menu option which allows you to quickly grab the new module code (modDebugPrint) for throwing into any project and use this thing.
There are tabs, so you can have different programs output debug info to separate tabs. To use them, there's a new DebugPrintToTab procedure in the modDebugPrint module. Here's the declaration:
Code:
Public Sub DebugPrintToTab(iTabNumber As Long, ParamArray vArgs() As Variant)
Just specify the tab you wish to DebugPrint to as iTabNumber, starting with 1, and it'll do that. If the tab doesn't exist, tabs are opened in the PersistentDebugPrint program such that your tab does exist. An iTabNumber=0 prints out to whatever tab currently has the focus. Any negative value in iTabNumber prints out to the largest tab number currently open in PersistentDebugPrint. Thanks to Eduardo for the custom tab control. It's a modified and cut-down version of what he has here.
The actual output textbox has a context menu with most of the same stuff that's in the main menu. The "Clear" and "Separate" are only for the tab with the focus. Font, BackColor, & ForeColor are global. Making those per-tab might be a future update.
And just as an FYI, the older DebugPrint procedure (if you've got it in existing projects) will still work with this new program. It'll just output to whatever tab has the focus (as if iTabNumber=0).
Here's a new screenshot:
Update #3: Fixed a bug in the modDebugPrint stub. The bug was that it only printed one line, now fixed.
If you download it, it's best to just compile it immediately. I just place the EXE on my desktop as I use it frequently. And then, just click the new "CodeForDebugPrint--->ToClipboard" option, and paste that code into a new module of whatever project you like. To use it, just replace your Debug.Print statements with DebugPrint (no period, with caveats noted above). Or, alternatively, use DebugPrintToTab.
Enjoy!
Last edited by Elroy; Dec 24th, 2022 at 03:06 PM.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.