Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default What are my variables ... ?


Hello everyone

I am currently imvolved in a large project, that started off as a very
small project, just a few lines of code, that has mushroomed to over a
thousand. I have not declared variables in this project, but would now
like to, but the problem is there are dozens, if not hundreds. Is there
a quick way for me to see/list all the variables so I know what they all
are and can start declaring them?

Secondly, can anyone tell me what is the benefit (if any) of
"compiling" the code (Debug ... Compile VBA Project) before I save it,
because it does appear to increase the file size, but does it offer any
benefits??

Thanks for reading

DJB


--
DJB
------------------------------------------------------------------------
DJB's Profile: http://www.excelforum.com/member.php...o&userid=21221
View this thread: http://www.excelforum.com/showthread...hreadid=384286

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default What are my variables ... ?


In reality not declaring variables/functions etc is a bad thing becaus
it slows down the execution time of the various routines and als
allows incorrect data to be assigned (such as strings to numerics etc)

Put


Code
-------------------

Option Explicit

-------------------


at the top of each module and then use the Compile function to attemp
to compile your code. It will stop at each undeclared variable.

Don't forget that functions also need typing:


Code
-------------------

Function My_Func(Arg1 as Integer, Arg2 as String) as String

-------------------


As for the benefits of "compiling" it highlights any errors before you
user see's them!

Regards

Ric

--
Rich_
-----------------------------------------------------------------------
Rich_z's Profile: http://www.excelforum.com/member.php...fo&userid=2473
View this thread: http://www.excelforum.com/showthread.php?threadid=38428

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default What are my variables ... ?


Hi Richz

Thanks for your answer. I know it's a bad thing which is why I want to
start declaring them.

Using the Option Explicit line was something I considered, but with the
number of variables I have this will take some time because when you do
a check the code always stops at the first undeclared variable,
irrespective of where the cursor is. I'd have to go back, declare it,
run the check again etc. I just wondered if there is a quicker way.

Strangely enough, I've declared all the variables in my functions, so
they're OK.

DJB


--
DJB
------------------------------------------------------------------------
DJB's Profile: http://www.excelforum.com/member.php...o&userid=21221
View this thread: http://www.excelforum.com/showthread...hreadid=384286

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default What are my variables ... ?


Heh!

The first line of code I always type (if VB is not set up to do it
is:

OPTION EXPLICIT

Regards

Ric

--
Rich_
-----------------------------------------------------------------------
Rich_z's Profile: http://www.excelforum.com/member.php...fo&userid=2473
View this thread: http://www.excelforum.com/showthread.php?threadid=38428

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default What are my variables ... ?

There is no quick way to see a list of all of the variables. The compiler
will not make that distinction until run time when it will create all of your
variables on the fly. I am with Rich... Add the Option Explicit and then hit
Debug - Compile. On the up side you learned to alway declare you variables
even in small projects. It is a good thing to learn.
--
HTH...

Jim Thomlinson


"DJB" wrote:


Hi Richz

Thanks for your answer. I know it's a bad thing which is why I want to
start declaring them.

Using the Option Explicit line was something I considered, but with the
number of variables I have this will take some time because when you do
a check the code always stops at the first undeclared variable,
irrespective of where the cursor is. I'd have to go back, declare it,
run the check again etc. I just wondered if there is a quicker way.

Strangely enough, I've declared all the variables in my functions, so
they're OK.

DJB


--
DJB
------------------------------------------------------------------------
DJB's Profile: http://www.excelforum.com/member.php...o&userid=21221
View this thread: http://www.excelforum.com/showthread...hreadid=384286




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
Not at all clear on use of variables and/or object variables JMay-Rke Excel Discussion (Misc queries) 11 July 4th 08 06:36 PM
Too many variables? elite Excel Worksheet Functions 2 May 19th 06 10:26 PM
Variables Phil Excel Programming 1 April 15th 05 04:39 PM
Using variables in RCs Mike D. Excel Programming 2 March 1st 05 10:53 PM
Looking up two variables Fish Excel Programming 1 February 11th 05 05:59 PM


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