30

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.

Community
  • 1
  • 1
Clay Nichols
  • 11,848
  • 30
  • 109
  • 170
  • 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 '09 at 20:27
  • Locking for historical records. – Lasse V. Karlsen Aug 09 '11 at 08: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](http://stackoverflow.com/tags/vb6/topusers). Do not close this question. Do not delete this question. – MarkJ Jan 18 '12 at 00: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](http://stackoverflow.com/tags/vb6/topusers). – MarkJ Jan 19 '12 at 17:10

24 Answers24

72

Enable mouse wheel in VB6:

Microsoft:enable the mouse scroll wheel

Martlark
  • 14,208
  • 13
  • 83
  • 99
  • Words fail, sorry I can't +5 you. – cmsjr Mar 19 '09 at 23:30
  • I wish I could +1 you over and over again, that's fantastic –  Mar 19 '09 at 23:44
  • I still have this as: favorite_vb6_addin.zip – Jim H. Mar 20 '09 at 00:49
  • +1 - Couldn't live without this one. – Mike Spross Mar 20 '09 at 02: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 '09 at 20:34
  • Definitely. I recommended this on a VB6-VB.NET project not too long ago and the developers there were ecstatic. They had been using a 3rd party plugin (don't recall the name) but it didn't work in split windows, whereas the MS one did and felt smoother to them. – Ahmad Mageed May 13 '09 at 23:06
  • +1, but the MS add-in doesn't work for VBA. At my company we use a free tool Gazanov VBScroll, which works with VBA and VB6 and also works in the SDI mode of the VB6 IDE. http://www.gasanov.net/VBScroll.asp – MarkJ Jun 25 '09 at 07:01
  • @MarkJ - awesome, I could not get the microsoft one working on win7 for some reason. This worked though. – cc0 Oct 22 '10 at 12:17
37

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

Clay Nichols
  • 11,848
  • 30
  • 109
  • 170
  • 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 '09 at 17:28
36

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 :)

MarkJ
  • 30,070
  • 5
  • 68
  • 111
15

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.

MarkJ
  • 30,070
  • 5
  • 68
  • 111
11

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

Clay Nichols
  • 11,848
  • 30
  • 109
  • 170
Shane Miskin
  • 1,911
  • 2
  • 22
  • 30
11

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.

MarkJ
  • 30,070
  • 5
  • 68
  • 111
AakashM
  • 62,551
  • 17
  • 151
  • 186
  • 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: http://brucem.mystarband.net/mckinney.htm – Don Kirkby Aug 10 '09 at 18:40
7

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.

Keith Maurino
  • 3,374
  • 10
  • 40
  • 48
6

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

cmsjr
  • 56,771
  • 11
  • 70
  • 62
  • 1
    Thanks, I've been looking for exactly that. Here's a link for those interested: http://vbnet.mvps.org/index.html?code/helpers/getarraydims.htm – Lance Roberts Mar 20 '09 at 00:10
  • Lance, thanks for the link, added to post. – cmsjr Mar 20 '09 at 00: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 '09 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 '09 at 07:52
  • Mister, your subscript is out of range. – cmsjr May 30 '09 at 23:00
  • @Oorang If you want to debug with Break on All Errors, this is a godsend. – Mark Hurd Aug 04 '10 at 05:35
  • 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 04 '10 at 14:55
6

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.

RS Conley
  • 7,196
  • 1
  • 20
  • 37
  • 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. http://www.amazon.com/Visual-Basic-Developers-Design-Patterns/dp/0782126928 – MarkJ May 12 '09 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. http://www.amazon.com/Microsoft-Visual-Design-Patterns-Professional/dp/1572319577 – MarkJ May 12 '09 at 15:39
6

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.

RS Conley
  • 7,196
  • 1
  • 20
  • 37
  • Maybe this is more appropriate to the "useful VB6 source code" question? http://stackoverflow.com/questions/232864/really-useful-vb6-source-code – MarkJ Mar 21 '09 at 18:23
5

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"

stone
  • 8,422
  • 5
  • 54
  • 66
5

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!

  • Good one! Also great for producing portable applications that run from a CD or flash memory drive. – Bob Apr 27 '09 at 15:27
4

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

AngryHacker
  • 59,598
  • 102
  • 325
  • 594
3

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.

AnthonyWJones
  • 187,081
  • 35
  • 232
  • 306
3

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.

MarkJ
  • 30,070
  • 5
  • 68
  • 111
2

CodeSmart 2009 for VB6

I've not tried this.

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

Clay Nichols
  • 11,848
  • 30
  • 109
  • 170
  • 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 '09 at 23:15
  • 1
    Yeah, MZ Tools is very well done. I"m planning to make a donation. – Clay Nichols May 10 '09 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. – Clay Nichols May 15 '10 at 02:22
2

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.

alex
  • 479,566
  • 201
  • 878
  • 984
2

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.

Ryan
  • 702
  • 1
  • 5
  • 11
  • Looks like the author moved the code (or re-listed the new version) at: http://www.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" – Clay Nichols May 09 '09 at 20:21
  • Thanks for the tip, edited to help the google machine help people. – Ryan May 11 '09 at 15:52
1

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.

Scott
  • 4,113
  • 6
  • 37
  • 49
  • AVE seems to be still alive and kicking : http://www.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 01 '12 at 12:39
1

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.

MarkJ
  • 30,070
  • 5
  • 68
  • 111
1

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.

MarkJ
  • 30,070
  • 5
  • 68
  • 111
1

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
Craig Gidney
  • 17,763
  • 5
  • 68
  • 136
  • 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. – Clay Nichols Apr 30 '09 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 '09 at 07: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 '09 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 01 '12 at 12:46
1

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

Oorang
  • 6,630
  • 1
  • 35
  • 52
0

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.