Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 188
Default Option Commands (Option Explicit / Option Base etc) - Scope


Hi All,

I have my VBE set to always use Option Explicit at the top of each new
module.

I occasionally use Option Base 0 or Option Base 1 as required.

If I use one of those at the top of any module within a project, does
it apply to *all* modules in that project unless and until explicitly
changed, or does it only ever apply to the module in which it resides?

Hope that is clear, but if not, feel free to ask me to explain more.

Thanks,

Alan.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Option Commands (Option Explicit / Option Base etc) - Scope

Module in which it resides.

--
Regards,
Tom Ogilvy

"Alan" wrote in message
...

Hi All,

I have my VBE set to always use Option Explicit at the top of each new
module.

I occasionally use Option Base 0 or Option Base 1 as required.

If I use one of those at the top of any module within a project, does
it apply to *all* modules in that project unless and until explicitly
changed, or does it only ever apply to the module in which it resides?

Hope that is clear, but if not, feel free to ask me to explain more.

Thanks,

Alan.





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Option Commands (Option Explicit / Option Base etc) - Scope

Hi Alan,

Usage of any of the Option statements is at module level.

It follows, therefore, that different Option statements can be employed with
different modules and, more particularly, that different Option Bases can be
employed in different modules.

---
Regards,
Norman



"Alan" wrote in message
...

Hi All,

I have my VBE set to always use Option Explicit at the top of each new
module.

I occasionally use Option Base 0 or Option Base 1 as required.

If I use one of those at the top of any module within a project, does
it apply to *all* modules in that project unless and until explicitly
changed, or does it only ever apply to the module in which it resides?

Hope that is clear, but if not, feel free to ask me to explain more.

Thanks,

Alan.





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 188
Default Option Commands (Option Explicit / Option Base etc) - Scope


"Tom Ogilvy" wrote in message
...
Module in which it resides.


Thanks Tom


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 188
Default Option Commands (Option Explicit / Option Base etc) - Scope


"Norman Jones" wrote in message
...
Hi Alan,

Usage of any of the Option statements is at module level.

It follows, therefore, that different Option statements can be

employed with
different modules and, more particularly, that different Option

Bases can be
employed in different modules.

---
Regards,
Norman


Thanks Norman.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Option Commands (Option Explicit / Option Base etc) - Scope

Alan,

Option Explicit only applies to the module in which it resides. All the
variables used in that module must be explicitly declared using Dim or one
of its variations (Public, Static, etc.)

Option Base also applies to only the module it is in.

--
John Green
Sydney
Australia


"Alan" wrote in message
...

Hi All,

I have my VBE set to always use Option Explicit at the top of each new
module.

I occasionally use Option Base 0 or Option Base 1 as required.

If I use one of those at the top of any module within a project, does
it apply to *all* modules in that project unless and until explicitly
changed, or does it only ever apply to the module in which it resides?

Hope that is clear, but if not, feel free to ask me to explain more.

Thanks,

Alan.





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 188
Default Option Commands (Option Explicit / Option Base etc) - Scope


"John Green" wrote in message
...
Alan,

Option Explicit only applies to the module in which it resides. All

the
variables used in that module must be explicitly declared using Dim

or one
of its variations (Public, Static, etc.)

Option Base also applies to only the module it is in.

--
John Green
Sydney
Australia



Thanks John.

As a follow up, does it therefore make sense to put all my public
variable declarations into a separate module on their own, and avoid
using public in other modules?

That way, if I only Dim vars in the other modules, I know they only
reside there.

How about forms? Should I also use option explicit in each separate
form, or do they all follow the same command?

Thanks,

Alan.



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Option Commands (Option Explicit / Option Base etc) - Scope

Alan,

As a matter of organization, I tend to put all public variables
and constants in their own separate module, typically named
modGlobals. You'll need to put Option Explicit in the code module
for each form.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Alan" wrote in message
...

"John Green" wrote in message
...
Alan,

Option Explicit only applies to the module in which it
resides. All

the
variables used in that module must be explicitly declared
using Dim

or one
of its variations (Public, Static, etc.)

Option Base also applies to only the module it is in.

--
John Green
Sydney
Australia



Thanks John.

As a follow up, does it therefore make sense to put all my
public
variable declarations into a separate module on their own, and
avoid
using public in other modules?

That way, if I only Dim vars in the other modules, I know they
only
reside there.

How about forms? Should I also use option explicit in each
separate
form, or do they all follow the same command?

Thanks,

Alan.





  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 188
Default Option Commands (Option Explicit / Option Base etc) - Scope


"Chip Pearson" wrote in message
...
Alan,

As a matter of organization, I tend to put all public variables
and constants in their own separate module, typically named
modGlobals. You'll need to put Option Explicit in the code module
for each form.


Thanks Chip.

I am only just getting to the level of complexity where these things
become an issue so it is all somewhat new to me (at least to have to
stop and really think about it systematically).

I guess I should extend my systematic naming conventions to the module
and form names too since there are getting to be many of them.....

Regards,

Alan.


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
Option Explicit [email protected] Excel Discussion (Misc queries) 5 April 30th 08 11:19 PM
option explicit Dave F Excel Discussion (Misc queries) 2 September 5th 06 02:46 PM
Option Explicit Grace[_4_] Excel Programming 6 June 12th 04 04:28 PM
Implied Option Explicit in XP?? Trip[_2_] Excel Programming 3 November 13th 03 12:24 AM
Option Explicit and Arrays Harlan Grove[_5_] Excel Programming 3 July 22nd 03 12:51 AM


All times are GMT +1. The time now is 10:43 AM.

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

About Us

"It's about Microsoft Excel"