Reputation: 505
Well Its been a while that i have had my hands in vb6. I have been declaring variables as
dim a,b,c as integer
But, today, while writing a program consisting of arrays, the declaration
dim ar(10),i,a as integer
yielded a wrong result. Then I changed my declaration to
dim ar(10) as integer,i as integer, a as integer
and the code worked. What is the difference between these two types of declarations?
Upvotes: 2
Views: 88
Reputation: 3381
You made an understandable error, one I have been caught with myself. When declaring variables the comma starts a completely new declaration.
So
dim ar(10),i,a as integer
is the same as
dim ar(10)
dim i
dim a as integer
Which as you can see declares 'ar' as an array of variants and 'i' as a single variant.
I avoid using the comma in a dim - it is just too easy for it to go wrong.
Upvotes: 10