Where to declare module-level variables?

  • Thread starter Thread starter Ed from AZ
  • Start date Start date
E

Ed from AZ

At the top of my module, I have
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As
Long)

I want to Dim some variables that will be used by several subs in this
module. Do I put them above the Private for the Sleep, or between
this and my first Sub?

Ed
 
Doesn't really matter. I tend to put APIs first, then private, then public
variables.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
It's a matter of taste.

Personally, I use very few module-level variables, preferring to pass
variables as arguments, but my preference would be to declare the
variables first.
 
Per Ed from AZ:
At the top of my module, I have
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As
Long)

I want to Dim some variables that will be used by several subs in this
module. Do I put them above the Private for the Sleep, or between
this and my first Sub?

My experience is that it Excel doesn't care.

I, however, prefer to have the Lib declarations as the last lines
in my module-level declarations.

No particular reason.... just started off that way. I'd guess,
the value is in consistency - whichever way you do it.
 
Back
Top