View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
atpgroups atpgroups is offline
external usenet poster
 
Posts: 40
Default Keeping Variables Alive

On 3 Jun, 21:25, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-
This-.com wrote:
Any globally declared varaibles are by default static. Normal procedure
variables are created on the stack. The stack is emptied after the procedure
is finished. Global and static variables are created on the heap. The heap is
only unloaded when the project ends (when the spreadsheet is closed). There
is one excpetion to this. If you use the stand alone code line "End" that
clears the heap and all varaibles along with it.


Interesting.
That is what I would expect, but not what I am seeing. I will check
through my program code for an "End" though (with 9000+ lines there is
plenty of scope for it to be hiding in a corner somewere)
However, in a much simpler bit of code I wrote recently I seemed to be
seeing the same thing. In that case a globally declared array of a
wrapper-class for an array of comboboxes was running the "Terminate"
event for each instance as soon as the code which created them was
completed. This either created them and instantly deleted them (with a
well-behaved "Terminate" routine) or left a bunch of orphan controls
on the worksheet (with no event handlers).
In that case I gave up and created the 15 comboboxes manually and copy-
pasted their event handlers 15 times each :-/

Thanks for the pointer, I will do some experiments. At the very least
I now have a new keyword to search on: "Heap"