I code with Vb6 everyday using my own convention and i'm starting to feel guilty about that.
Do you know any style guides for VB6 like naming convention, code techniques and best practices?
views:
77answers:
5I would not be concerned with any "standard" style for VB6 coding at this point. The important thing is that you are consistent with the existing code base.
In my opinion it should not matter what style you use as long as you are consistent. However you should be flexible enough to write in the house style of your employer too.
Despite VB6's infamy in legacy codebases, it is still used heavily every day in lots of enterprises and it will benefit from good style.
As Darrel suggested, be consistent with existing code bases.
However, if you have freedom in how you style your code, you might choose the Reddick VBA Naming Convention (VBA is the same codebase as VB6). It's recommended in the VBA Developer's Handbook. Granted, a lot of its style will feel obsolete in the .NET environment, but it does seem to be heavily used a lot in VB6 and VBA examples.
Microsoft's own coding guidelines in the VB6 manual are pretty good.
- Like Darryl says, when editing existing code, it's best to match the naming conventions, indenting, and commenting style in the existing routine or module. You can be more creative when creating new modules.
- However there are some best practises that should always be applied (e.g. before editing a module without
Option Explicit
I would addOption Explicit
before doing anything else).
I found Practical Standards for Microsoft Visual Basic to be quite good. It's from the classic vb era and is available for as little as 1 cent (plus delivery).