Skip to content

Coding To Be Lazy

I know a lot of people like to write their local variable declarations like this:

dim i, i, j as integerdim k as double, s as string, b as boolean

Personally, I don’t and the reason is not that I like typing…

If you write one line of declarations, the compiler will flag only one error or unused variable per line. So when you run or analyze you code, the compiler will find one error or unused variable per line and then you’ll have to repeat this process, over and over, as many times as you have errors in that one line.

But, if you write one declarations per line, the compiler can flag them all in the first pass. Try it. Write two methods. One with this declaration:

dim a, 1b, 2c, 3c as integer

and another with this group of declarations:

dim a as integer
dim 1b as integer
dim 2c as integer
dim 3c as integer

Then analyze the project. In the first case it will flag 1b as an error. Remove that bad declaration and analyze again and again until you get all the errors fixed. In the second it highlights them all as errors in the first pass and you can fix all of them after the first analyze. Save yourself some time!