tstav
03-24-2008, 02:13 AM
Good day everybody,
Dim intA, intB, intC as integer, lngL as long
Dim blnB, blnC as Boolean
The above is just an example of declaring various variables.
I see this particular way of declaring variables so often that I kind of started thinking it is correct. But it isn't.
In the above, even though the intention seems to be to declare intA and intB as type integer and blnB as type Boolean, this is not what happens. They all are of type Variant because no explicit type has been mentioned for them.
This is what Microsoft says about it:
' Multiple declarations on a single line. AnotherVar is of type Variant
' because its type is omitted.
Dim AnotherVar, Choice As Boolean, BirthDate As Date
Dim intA, intB, intC as integer, lngL as long
Dim blnB, blnC as Boolean
The above is just an example of declaring various variables.
I see this particular way of declaring variables so often that I kind of started thinking it is correct. But it isn't.
In the above, even though the intention seems to be to declare intA and intB as type integer and blnB as type Boolean, this is not what happens. They all are of type Variant because no explicit type has been mentioned for them.
This is what Microsoft says about it:
' Multiple declarations on a single line. AnotherVar is of type Variant
' because its type is omitted.
Dim AnotherVar, Choice As Boolean, BirthDate As Date