ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Option Commands (Option Explicit / Option Base etc) - Scope (https://www.excelbanter.com/excel-programming/315349-option-commands-option-explicit-option-base-etc-scope.html)

Alan

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.




Tom Ogilvy

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.






Norman Jones

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.






Alan

Option Commands (Option Explicit / Option Base etc) - Scope
 

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


Thanks Tom



Alan

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.



John Green[_4_]

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.






Alan

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.




Chip Pearson

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.






Alan

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.




All times are GMT +1. The time now is 03:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com