Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
ending subs
just a quickie, I have a lot of subs that call other subs. I usually
do this at the bottom of the sub i.e sub example() various code call example2 end sub by doing this does the example sub stay active until example 2 sub has ended, if so if i have afew of these going on does it become a drain on the programs performance. if so is there a way of ending example sub from example2 as i have no more need for it regards Tammy |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
ending subs
Does the higher sub stay "active"? No. When the nested sub completes the
higher sub regains focus and execution continues at the line after the call statement. This is not a drain on the system because the higher sub pauses until the called routine completes. P.S. you can also call subroutines without the "call" statement. But when you leave out the "call" keyword you must also leave out the parentheses surrounding any args. The following examples are different syntax to do exactly the same thing: Call DoThis(txt, "hello", Yes, ipos) DoThis txt, "hello", Yes, ipos " wrote: just a quickie, I have a lot of subs that call other subs. I usually do this at the bottom of the sub i.e sub example() various code call example2 end sub by doing this does the example sub stay active until example 2 sub has ended, if so if i have afew of these going on does it become a drain on the programs performance. if so is there a way of ending example sub from example2 as i have no more need for it regards Tammy |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
ending subs
Charlie's answer is correct. Just to add my two cents, think of procedures
and functions like building blocks. When you call a sub or function you place that block onto the stack. If a sub calls another sub or function then that sub or function is placed on the stack. Blocks can only be removed from the stack when there is no block on top of them and they are finished. So no you can not remove the calling block because the called block is sitting on top of it. Here is where things get interesting. If you make a call within a loop that executes for example 1000 times then the block needs to be placed on the stack and taken off the stack 1000 times. If you have an overriding need for speed (not too often but it can happen) then instead of calling a procedure, place the code for the called procedure right in the calling procedure (referred to as inlinning your code). Now you are not having to add and remove the block 1000 times. ONLY do this if you NEED extra speed. HTH " wrote: just a quickie, I have a lot of subs that call other subs. I usually do this at the bottom of the sub i.e sub example() various code call example2 end sub by doing this does the example sub stay active until example 2 sub has ended, if so if i have afew of these going on does it become a drain on the programs performance. if so is there a way of ending example sub from example2 as i have no more need for it regards Tammy |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Combining two Subs | Excel Discussion (Misc queries) | |||
Private subs | Excel Programming | |||
Stringing Subs | Excel Programming | |||
calling subs | Excel Programming | |||
Recursive Subs? | Excel Programming |