Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
Option Commands (Option Explicit / Option Base etc) - Scope
"Tom Ogilvy" wrote in message ... Module in which it resides. Thanks Tom |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Option Explicit | Excel Discussion (Misc queries) | |||
option explicit | Excel Discussion (Misc queries) | |||
Option Explicit | Excel Programming | |||
Implied Option Explicit in XP?? | Excel Programming | |||
Option Explicit and Arrays | Excel Programming |