If you have used C-style languages, you may be used to this notation:
int x, y, z;
which declares 3 variables
x,
y, and
z of the type
int.
You may have also used this in VB.NET:
Dim x, y, z As Long
which declares the three variables of type
Long.
So it's only natural that you would expect to do the same in VB6 (or earlier). Unfortunately, pre VB.NET, the syntax does not mean the same thing. If you declare a variable without specifying a type, you are effectively declaring it as a Variant.
Dim x ' x is a Variant
Declaring multiple variables in the shorthand manner seen above will result in
x and
y typed as
Variant, and only
z as a
Long, when you intended all three to be
Long's.
In Visual Basic.NET Variants were removed from the language altogether as they did not fit with the .NET type system. The statement
Dim x in VB.NET actually declares
x as an
Object, but the behaviour of the shorthand declaration was changed so that all untyped variables are declared as the next type keyword that appears in the declaration statement. Just remember that this is NOT the case in Classic VB