30
votes

This is somewhat related to a similar post, but that post was Visual Studio 6 in general and a lot of the suggestions didn't apply to Visual Basic 6.0.

Suggest or vote for tools/tips. Please one tool/tip per post so that everyone can vote on them individually. Include a brief description of what the tools do.

4
  • 3
    Please everyone, put a brief description of what the tools actually do in your answer. Folks will not necessarily click your link to the tool's website to find out what it does.
    – MarkJ
    Mar 23, 2009 at 20:27
  • Locking for historical records. Aug 9, 2011 at 8:25
  • 2
    This is a constructive question. The answers have no arguments, opinion, debate or extended discussion. There are many facts, references and specific expertise. Do not close this question. Do not delete this question.
    – MarkJ
    Jan 18, 2012 at 0:05
  • 2
    @Sam Saffron can I appeal for this question to be reopened and not deleted please? This is a constructive question. The answers have no arguments, opinion, debate or extended discussion. There are many facts, references and specific expertise. As far as I can judge it's very useful, and for whatever it's worth, I am the top-voted user on the VB6 tag.
    – MarkJ
    Jan 19, 2012 at 17:10

24 Answers 24

72
votes

Enable mouse wheel in VB6:

Microsoft:enable the mouse scroll wheel

8
  • Words fail, sorry I can't +5 you.
    – cmsjr
    Mar 19, 2009 at 23:30
  • I wish I could +1 you over and over again, that's fantastic
    – user65628
    Mar 19, 2009 at 23:44
  • I still have this as: favorite_vb6_addin.zip
    – Jim H.
    Mar 20, 2009 at 0:49
  • +1 - Couldn't live without this one. Mar 20, 2009 at 2:22
  • +1, thankfully there are add-ins that you can use to enable it. I didn't see the microsoft link, thanks.
    – Sukasa
    Mar 23, 2009 at 20:34
37
votes

MZ Tools.

Free. Lots of extra tools for the IDE, like "Favorite Procedures" and "Add error routine to prodedure" and lots more.

http://www.mztools.com/v3/mztools3.aspx

1
  • 1
    I also love the "show all callers to this routine" and the find command which shows you all results in a docked window. Used to drop out to an external editor to do that before I found MZTools.
    – MarkJ
    Mar 20, 2009 at 17:28
36
votes

After installing VB6, I always do these customisations on Tools-Options.

  • Switch off Auto Syntax Check on the Editor tab. You don't want message boxes when you type a syntax error - you just want the problem line shown in red so you can fix it later.

  • Switch on Require Variable Declaration on the Editor tab. Don't think, just do it.

  • Switch off Compile On Demand on the General tab. You want to be told about syntax errors immediately when you run your code, not just when the dodgy routine actually gets called.

  • EDIT: Prompt to save changes when program starts, on the Environment tab. (Thanks wqw for reminding me in the comments.)

  • Set Error Trapping to "Break on unhandled errors" on the General tab. Actually, this is a personal preference - but you should select the setting that suits you. Hopefully you've worked out an error handling strategy for the VB6 program?

  • I have an LCD screen, and the default colours don't work very well, so I change them to lighter ones. I'm also using the Consolas font. Makes my VB6 code look twenty-first century anyway :)

5
  • 8
    Switch Off Auto Syntax Check is GREAT! Never knew that was a possibility. That error popup has been bugging me for YEARS! Mar 24, 2009 at 15:50
  • Wow. I didn't know about Switch Off Auto Syntax Check either. That is super awesome. Apr 8, 2009 at 22:37
  • 1
    Somtimes it's convenient to only part complete a line of code while you go and copy an expression and that error message box was a pain in the neck. Thanks!!
    – kjack
    Apr 8, 2009 at 23:37
  • 1
    All of these and "Prompt to save changes"
    – wqw
    Oct 11, 2009 at 21:00
  • 1
    Very nice. Consolas make vb look way better on the HD.
    – lb.
    Jan 19, 2010 at 2:27
15
votes

It's amazing how many people don't use the IDE buttons for commenting-out and uncommenting blocks of source code. They are on the Edit toolbar and look like this: alt text http://img231.imageshack.us/img231/1949/vb6commentbuttons.gif. Right-click in an unoccupied part of the toolbar area and tick the Edit option to display the toolbar.

I once attended an "Advanced VB6" course where the instructor didn't know about those buttons.


EDIT: AngryHacker has a way to associate shortcut keys with these buttons to comment and uncomment code blocks at a keystroke.

2
11
votes

I can't believe no one has yet posted Bruce McKinney's Hardcore Visual Basic (now free online on mvps.org)! OK it's a book rather than a piece of software, but it expands to a veritable cornucopia of tools and tips.

1
  • 2
    I loved this book. Any other fans will probably also be interested in the ill-fated tale of the third edition, along with errata and sample code: brucem.mystarband.net/mckinney.htm
    – Don Kirkby
    Aug 10, 2009 at 18:40
11
votes

SmartIndenter takes care of all the auto-indenting. It does one thing and it does it really well. And it's free.

http://www.oaltd.co.uk/Indenter/Default.htm

SmartIndenter http://img151.imageshack.us/img151/1392/screencaps1.jpg

1
  • 1
    It's a nice tool, but for the love of VB6, don't write ridiculous unindented code to begin with. Jan 8, 2011 at 0:05
7
votes

The vbAccelerator website. It has so many great examples and free controls with the full source. The site has not been updated in a few years now, but it still keeps running and I still go back to it when working in VB6.

1
  • +1, but you might want to fix the typo in the website name!
    – MarkJ
    May 2, 2009 at 10:01
6
votes

I realllly hate checking to see if an array is uninitialized by passing it to a helper function that tries to do a UBound and catches the error if it occurs.

Solution?

Use VarPtr to get the array's address, pass the address to CopyMemory to get the SafeArray structure for the array, if the SafeArray structure indicates 0 dimensions, the array is uninitialized.

EDIT thanks to Lance for good link with example

http://vbnet.mvps.org/index.html?code/helpers/getarraydims.htm

7
  • 1
    Thanks, I've been looking for exactly that. Here's a link for those interested: vbnet.mvps.org/index.html?code/helpers/getarraydims.htm Mar 20, 2009 at 0:10
  • Lance, thanks for the link, added to post.
    – cmsjr
    Mar 20, 2009 at 0:16
  • 1
    Long long ago I would have said tricks like this make it harder to upgrade your code to the next version of the language. HA!
    – MarkJ
    Mar 20, 2009 at 17:49
  • lol I'm laughing because it totally sounds like something I would do. But honestly... Introducing RTLMoveMemory just to avoid testing by exception? I think the risks outweigh the rewards. Especially when your program stops working when MS nukes unsafe API calls.
    – Oorang
    May 30, 2009 at 7:52
  • 1
    @Mark Hurd, I'll conceed that point. May stance isn't really "never do that" so much as it is "have a good reason before you do that". That's a pretty good reason:)
    – Oorang
    Aug 4, 2010 at 14:55
6
votes

The entire mvps.org site here

I recommend Karl Peterson' One stop source and Randy Birch's VBnet (which has nothing to do with VB.NET) and Common Controls Replacement Project.

1
6
votes

Design Patterns by the GoF. While it doesn't seem specific for VB6 the fact that most of the patterns are based interface implementation and aggregating objects (as opposed to inheritance) makes it well suited for use with VB6. They talk about this on pages 16 to 18 and sum it up in one statement. Program to an interface, not an implmentation If there is one thing that VB6 and COM does well is handle interfaces.

2
  • 1
    +1. Can I also plug the book "Visual Basic Developer's Guide to UML and Design Patterns" by Griver etc? Explains design patterns in 100% VB6, discussing issues like circular references. Anyone whose main experience is in VB6 might find the gang of four book difficult, I recommend this fine book instead. amazon.com/Visual-Basic-Developers-Design-Patterns/dp/…
    – MarkJ
    May 12, 2009 at 15:36
  • There is also Microsoft Press's "Visual Basic Design Patterns" by Stamatakis. Personally I hated it (it covers only 7 gang of four patterns and is poorly written). But some folks on Amazon have given it good reviews. amazon.com/Microsoft-Visual-Design-Patterns-Professional/dp/…
    – MarkJ
    May 12, 2009 at 15:39
5
votes

Make My Manifest can produce Reg-Free COM manifests (chucking in "Styles" as needed, etc.). This allows XCopy deployment of many VB6 EXEs to WinXP or later.

No more "dependency" fears or DLL Hell!

1
  • Good one! Also great for producing portable applications that run from a CD or flash memory drive.
    – Bob
    Apr 27, 2009 at 15:27
5
votes

The VB6 IDE doesn't remember your preference for maximizing the code windows. To start up with the VB6 code windows maximized, set this string registry key:

[HKEY_CURRENT_USER\Software\Microsoft\Visual Basic\6.0]

"MdiMaximized"="1"

4
votes

Check out http://angryhacker.com/blog/archive/2008/05/01/vb6-swiss-army-knife.aspx

It has most tools I use for whenever I have to delve into VB6, plus a description of what they do. In addition to the tools mentioned here, it also has the following:

PDSA Property Creator

ADO Stored Proc Generator Add-in

Collection Class Master Add-in

3
votes

Matt Curlands Power VB book and the VBoost tools that came with it, especially the Type library editor.

Just watch out for the non-DEP compliant techniques.

1
  • The title was "Advanced Visual Basic 6"
    – MarkJ
    Jul 31, 2009 at 16:01
3
votes

The vbAdvance add-in is now free.

vbAdvance is a Visual Basic Add-In that gives you access to advanced build features and many IDE convenience features. Create console apps, create standard DLLs that export functions, create a DllMain entry point in your DLLs, XP Manifest compiler for XP styles, Terminal Server, etc.

2
votes

CodeSmart 2009 for VB6

I've not tried this.

http://www.axtools.com/products/cs2k3vb_screenshots.htm

3
  • I have the last version of CodeSmart. It has some useful code analysis features, but I use MZTools 99% of the time and CodeSmart 1%.
    – CtrlDot
    Mar 20, 2009 at 23:15
  • 1
    Yeah, MZ Tools is very well done. I"m planning to make a donation. May 10, 2009 at 21:08
  • I looked @ Codesmart again and it has some really cool code navigation features like hyperlinks amongst code, as well as showing visually which IF a particular THEN goes with, graphically illustrating the flow of CASE statements. Mztools has cool stuff bit it's a bit hard to access (i.e., to find references : right click, Mztools, sub menu- References, etc. May 15, 2010 at 2:22
2
votes

I discovered a lot of things when I was first learning by using the wizards to make forms/small applications, and then examining the code they output.

2
votes

One great tool that is out there and I've used is called CodeFixer. I believe I first stumbled across CodeFixer here.

It's even open source. I have had a little contact with the author, Roger Gilchrist, and he seems to still be working on it in his, surely limited, free time.

2
  • Looks like the author moved the code (or re-listed the new version) at: pscode.com/vb/scripts/ShowCode.asp?txtCodeId=59247&lngWId=1 Also, Ryan, if you include the name codefixer in the link it'll make it easier for folks to find if they google on just codefixer (i.e., gets some google-seo-juice applied to that link for the term "codefixer" May 9, 2009 at 20:21
  • Thanks for the tip, edited to help the google machine help people.
    – Ryan
    May 11, 2009 at 15:52
1
vote

VB6 error handling sucks. So I've adopted these patterns to make it easier:

The Try-Catch block:

    'Try
        On Error Goto catchX

        ...

    'Catch
catchX: if err.number then
            ...
            resume resumX
resumX: end if
        On Error Goto outside_catch_label_name
    'End Try

Including a stack trace in errors:

sub rethrow(byval source as string)
    Err.Source = Err.Source & vbNewLine & vbTab & "@ " & Source
    Err.Raise Err.Number, Err.Source, Err.Description
end sub

sub some_sub: on error goto throw
    ...
throw: if err.number then rethrow("some_sub")
end sub
4
  • 3
    FYI, MZ-tools (free addon listed in this Question) has a feature to let you automatically add Error Trapping. And you can configure it somewhat like a mail merge. Pretty slick. Apr 30, 2009 at 20:24
  • 2
    You know I just never got why people don't like VB's error handling. Am I missing something?
    – Oorang
    May 30, 2009 at 7:53
  • 2
    @Oorang: I disliked it because it's too close to BASIC's GOTO/GOSUB roots. For programmers who are used to a more structured try/catch or try/finally style, it feels like a huge step backward. If you like the power and flexibility of GOTO, then enjoy yourself. But you should keep in mind the mental tax you're paying every time you ensure that you've wired up your error handling correctly.
    – Don Kirkby
    Aug 10, 2009 at 18:47
  • My favourite error handling method for VB6 was to use HuntERR31 - but I can't find a place to download it anymore. Combined with a custom template for error handling, and a tweak to one of the other IDE plugins to insert the right handler in routines based on their name (broadly, method names with underscores in them are event handlers), and you had the closest thing possible to structured exception handling in VB6 - full stack traces and everything. Went from major headscratching to pinpointing the exact line an error was on. Will see about hosting a copy somewhere.
    – Adrian
    Feb 1, 2012 at 12:46
1
vote

I haven't tried this myself yet, but CodeShine is a cheap refactoring add-in for VB6. It can do the useful extract method refactoring, apparently.

I must stop wasting time here and download the free trial to try it out.

1
vote

Aivosto's Project Analyzer http://www.aivosto.com/project/project.html

1
vote

Spider Eye Flexbag

The collection class replacement from Spider Eye called Spider Eye Flexbag is an absolute must. Its 100% better than the collection classes that ship with VB and its blindingly fast compared to the original collections. The Flexbag collection was written by Gary Wisniewski of "Carl 'n Gary's Visual Basic Home Page" fame.

Unfortunately the Spider Eye website doesn't seem to have a link to the Flex Bag at the moment, but I'm sure if you contact them they'd be happy to sort something out for you. If you are doing any collection based work at all then it would be well worth the effort.

AVE Code Finder

The AVE Code Finder is handy because the Find function in the VB6 IDE can't be trusted. AVE Code Finder is also much much faster then the built in Find. It was written by Jarek Zwierz of www.ave.com.pl but the site doesn't seem to exist anymore so the version I've linked to is at VB2TheMax.

1
  • AVE seems to be still alive and kicking : ave.com.pl/default.aspx?menuid=files&submenuid=s4 : I've also been inspired to send them my personal enhancements to AVE Code Finder - Options for regex, in comment / not in comment, compatibility with VBA, and a couple of minor tweaks like changing the default focus to the combo box and changing the font to the more readable Lucida Console.
    – Adrian
    Feb 1, 2012 at 12:39
1
vote

The VB6 Credits Easter Egg that lists the development team :)

To show the VB6 Program Credits create an 'About' button to the standard toolbar and rename its caption to 'Show VB Credits'. Here's a bit more detail:

  1. Right-Click on a toolbar and select 'Customize'
  2. Within the 'Commands' tab select the 'Help' category
  3. Drag the 'About Microsoft Visual Basic' command (right windows of dialog box) up to the end of the standard toolbar.
  4. Without closing the 'Customize' dialog box, Right-Click on the button you just created and change its Name to 'Show VB Credits'
  5. Close 'Customize' and click the new button.

Bonus points for spotting famous names.

0
votes

I purchased the Codejock SuitePro for my company. They have many components to be used in VB6 and C++, including the support to XAML in controls, that is a lightweight version of the WPF.

Not the answer you're looking for? Browse other questions tagged or ask your own question.