Where to declare module-level variables?

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
 
B

Bob Phillips

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)
 
J

JE McGimpsey

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.
 
P

(PeteCresswell)

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top