views:

59

answers:

1

I want your thoughts on why or (why not) this statement should (or should not) be used.

Since this is a little subjective, here is my criteria: Upvotes given for concrete reasons (as opposed to unreasoned opinion). Final answer accepted will be the most comprehensive answer.

+5  A: 

In a well-crafted program, Defxxx statements are pointless, because all variables and functions will be explicitly typed.

Except for one case: DefObj A-Z, in conjunction with Option Explicit, makes it (practically) impossible for any untyped or undeclared variable, function, or member to exist in your code, and makes anything that would wind up as a Variant stand out in sharp relief.

DefObj A-Z is the suspenders to Option Explicit's belt.

Jim Mack
+1 Neat trick:)
Oorang
Side note: In my boredom, I said unto myself "Yea, I shall commit a most grievous coding party foul and us Extended ASCII variables to defeat this new trick." But guess what? Even though A-Y only covers A through Y A-Z actually covers *everything* extended ASCII included.
Oorang
+1 Clever trick. Took the liberty of editing the answer to add some links to the VB6 reference manual. Usually I disapprove of DefType, Option Compare, etc because you have to look at the top of the module before you know what code is doing. But this is good.
MarkJ
You know, I was playing around with Option Compare last night, and I did find one interesting thing. If you need to sort or compare case-insensitively, Option Compare Text blows StrComp and LCase$ out of the water. By a lot. I hate to alter an entire module's compare method, but for certain heavy duty applications this could be a gain worth taking advantage of.
Oorang