Thread: ending subs
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson[_3_] Jim Thomlinson[_3_] is offline
external usenet poster
 
Posts: 983
Default 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