PC Review


Reply
Thread Tools Rate Thread

Where to declare module-level variables?

 
 
Ed from AZ
Guest
Posts: n/a
 
      20th Aug 2007
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

 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      21st Aug 2007
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)

"Ed from AZ" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
JE McGimpsey
Guest
Posts: n/a
 
      21st Aug 2007
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.

In article <(E-Mail Removed)>,
Ed from AZ <(E-Mail Removed)> wrote:

> 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

 
Reply With Quote
 
Ed from AZ
Guest
Posts: n/a
 
      21st Aug 2007
Thanks to you both. I appreciate the boost.

Ed

 
Reply With Quote
 
(PeteCresswell)
Guest
Posts: n/a
 
      21st Aug 2007
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.
--
PeteCresswell
 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      21st Aug 2007
I'd use multiple modules.

One for the APIs and one for the public variables.



Ed from AZ wrote:
>
> 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


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Declaring Variables at Module level and Procedure level =?Utf-8?B?R3JhZW1l?= Microsoft Access VBA Modules 5 28th Feb 2007 03:31 PM
Module level variables withing <%=%> tags... J.K. Bach Microsoft ASP .NET 0 15th Jun 2005 03:57 PM
Module-level variables and multiple threads in IIS Oenone Microsoft ASP .NET 2 2nd Jun 2005 05:35 PM
use of module level variables =?Utf-8?B?VHhSYWlzdGxpbg==?= Microsoft Excel Programming 2 3rd Mar 2005 10:41 PM
Module-Level Variables Ying Microsoft Excel Worksheet Functions 2 22nd Sep 2003 04:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:33 PM.