Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 921
Default Prevent Overloaded variables

Hi,

I have some variables declared at the top of the module, so they are used
throughout the program. But here is the problem, I can redeclare the
variable inside another sub procedure, how do I prevent this? This seems
like bad feature to have in excel.

I declared option explicit at the top.

Thanks for your help.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,316
Default Prevent Overloaded variables

I use a naming convention so that variables declared at the top of a molule
as constants have a 'con' prefix. So if I have a constant named conFilePath
and I need to declare a file path string variable in another sub or
funcition, in the a sub or function I use a 'str' prefix to denote a string
variable.

That would eliminate conficting names at the module, and procedure level.
--
Kevin Backmann


"Jeff" wrote:

Hi,

I have some variables declared at the top of the module, so they are used
throughout the program. But here is the problem, I can redeclare the
variable inside another sub procedure, how do I prevent this? This seems
like bad feature to have in excel.

I declared option explicit at the top.

Thanks for your help.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Prevent Overloaded variables

I think you should search VBA's help for: Understanding Scope and Visibility

Someday, you may appreciate the fact that you can do what you don't want to do
today.

Jeff wrote:

Hi,

I have some variables declared at the top of the module, so they are used
throughout the program. But here is the problem, I can redeclare the
variable inside another sub procedure, how do I prevent this? This seems
like bad feature to have in excel.

I declared option explicit at the top.

Thanks for your help.


--

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
Too Many Variables Heliocracy Excel Worksheet Functions 6 April 6th 07 07:02 PM
HOW CAN I PREVENT EXCEL FILES FROM BEING DELETED OR PREVENT TRASH ROB Excel Discussion (Misc queries) 2 April 2nd 07 01:13 PM
How do I add variables Jez Excel Discussion (Misc queries) 1 January 15th 07 08:33 AM
Variables in VBA Jeff Excel Discussion (Misc queries) 2 October 17th 06 02:30 PM
Too many variables? elite Excel Worksheet Functions 2 May 19th 06 10:26 PM


All times are GMT +1. The time now is 08:53 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"