Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Manipulation of the CALL STACK, possible?

Status
Not open for further replies.

Antequonopolistant

Programmer
Sep 17, 2002
6
AU
Good day,
We have developed a program that uses 29 different user forms ontop of Miscrosoft Excel 97. The forms get all the inputs and settings from users and then use Excel Charts for pretty graphical output. Each form will (when no longer wanted by the user) activate the next one.

Problem is: each form may be called many times...
Leading to: Stack overflow, out of stack space...

Is there any way to stop a form from being added to the call stack and then have it activate another form?

Unload UForm27
UForm28.Show

UNLOAD does not stop the form from being placed onto the stack.
The form just needs to GO AWAY and activate the next one...

Any useful hints about methods or events somewhere I can use to either remove the stack entry or stop the form from being placed there in the first place?

Thanks in advance. :)
- Damian.
 
Instead of calling the next form from the previous one, manage the control of your various forms through a module-level sub and a public variable. Something like:

(in module1)
public GoForm as integer

sub DoForms
GoForm=1 'default first form
do
select case GoForm
1:Form1.show
2:Form2.show
..etc...
end select
loop until GoForm=0
end sub

(in Form1)

sub btnClose_click
GoForm=0
unload me
end sub

sub btnForm2_click
GoForm=2
unload me
end sub

and similarly for other forms. Make sense? I don't think you'll have stack problems if you run it that way.
Rob
[flowerface]
 
Nope, doesn't work. Thanks for the help though. :)

I already have code for a 'PREVIOUS' button and a manual statically maintained stack for where user came from form before...

This uses a huge SELECT statement as in your example.

Problem with this is --> The call to the Module level SELECT code is placed on the stack, AND the call from the module code to another form is then placed onto the stack. The UNLOAD on the next line does not actually get completed until the forms are closed and the stack unwound...

UNLOAD before the module select call does not work either, still ends up on the stack.

Thanks again for your help... :):)

Any other ideas anyone?
 
I think you misinterpreted my suggestion. My code does NOT call one form from within another form. Each form is closed completely, and control returned to the bottom-level sub, before any other form is opened. I'm quite sure that this works for me - can you tell me in what way it doesn't do what you need it to? Rob
[flowerface]
 
Boing!! Thankyou RobBroekhuis. I DID misinterpret it!

See my code does the exact same thing BUT it calls the sub.

Whereas yours just sets a global then the form dies and the sub takes over again!

When I first saw your code, the set out etc, little bits of code at a glance looked exactly like mine anyway, so I thought it was the same.

But YES! Thankyou for re-iterising your suggestion. It make perfect sence! And is so simple! And now I can't see why I didn't think of that in the first place! ... If stack keep filling up, then let forms die anyway!

Ok, bye for now, I have a sub and many many form code-snippets to modify... :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top