views:

77

answers:

5

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?

+1  A: 

I 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.

Darrel Miller
@Darrel there's a problem. This big piece of software was handled by 8 different programmers since 2004 and everyone has used his own style (i know its a common scenario with old project in VB6). I've tried to follow some common pattern in this mess but it's pretty difficult.
systempuntoout
+1 For naming conventions, indenting, commenting style: try to fit in with the routine or module you are changing. On the other hand there are some best practises that should always be applied (e.g. use of Option Explicit)
MarkJ
A: 

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.

Dan Iveson
+3  A: 

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.

Ben McCormack
@Ben Reddick suggests to use naming like lngCount, intValue, strInput..i'm a little bit puzzled.
systempuntoout
@system I'm not sure why you're puzzled. Some people use Hungarian style for their variables frequently, esp. in older languages, but it's fallen out of style in .NET and other modern compiled languages with strong IDE support. So are you puzzled because you prefer not to use Hungarian or because you question why I say that "a lot of its style will feel obsolete..."?
Ben McCormack
@Ben i'm simply puzzled because no one in the codebase i work has ever used Hungarian notation :).
systempuntoout
+2  A: 

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 add Option Explicit before doing anything else).
MarkJ
+1  A: 

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

jjb