Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default Where to declare module-level variables?

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Where to declare module-level variables?

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" wrote in message
ups.com...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Where to declare module-level variables?

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 . com,
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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default Where to declare module-level variables?

Thanks to you both. I appreciate the boost.

Ed

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 139
Default Where to declare module-level variables?

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


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Where to declare module-level variables?

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Declare and Set Public variables jlclyde Excel Discussion (Misc queries) 2 January 28th 09 02:16 PM
Declare a class module in General Declarations Wilbur[_8_] Excel Programming 1 March 12th 06 03:52 PM
Declare at application level MD Excel Programming 1 June 28th 05 06:23 PM
use of module level variables TxRaistlin Excel Programming 2 March 3rd 05 10:41 PM
how to declare a class module Kevin Excel Programming 5 July 15th 03 01:04 AM


All times are GMT +1. The time now is 05:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"