Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Not at all clear on use of variables and/or object variables | Excel Discussion (Misc queries) | |||
Too many variables? | Excel Worksheet Functions | |||
Variables | Excel Programming | |||
Using variables in RCs | Excel Programming | |||
Looking up two variables | Excel Programming |