How do you organize your variable declarations?

Viewed 47

I want to hear how others go about this, and why, to see if there is a better method that what I do.

Do you do this:

dim x as long
dim y as long
dim a as string
dim b as integer
dim c as integer
dim d as integer

or this:

dim x as long, y
dim a as string
dim b as integer, c, d

or do you declare them as they are needed within the script? or something else?

I have a few scripts that have 60+ variables, and how to organize them is something I always question

thanks!

1 Answers
dim x as long, y as long
dim a as string
dim b as integer, c as integer, d as integer

You have to specify the type of each variable, otherwise it will be a variant.
Don't forget to set the VBE option to automatically insert OPtion explicit at the top of each module. It will save you time and sweat.

A common practice is to have all your DIMs at the top of the module/function/sub

Related