Closing a Form...

  • Thread starter Thread starter Moshazu
  • Start date Start date
M

Moshazu

I am attempting to close an mdiChild form, but when I call for it to
close, it will still fire additional code in the method that called the
close. How do I make sure that this does not happen?

Thanks,
Darian
 
Moshazu said:
I am attempting to close an mdiChild form, but when I call for it to
close, it will still fire additional code in the method that called the
close. How do I make sure that this does not happen?

Thanks,
Darian

Do:

Me.Close
Exit Sub

Chris
 
Thanks for the reply, Chris

That will work if the close was called in a non-nested method, but in
my case, the method that calls the close, is called from another
method, which will continue its code once the Exit Sub from the nested
method was called.

Anyway around this one?
 
Moshazu said:
Thanks for the reply, Chris

That will work if the close was called in a non-nested method, but in
my case, the method that calls the close, is called from another
method, which will continue its code once the Exit Sub from the nested
method was called.

Anyway around this one?

If you can't easily change your call structure to be to return a value
that let's the call stack know it needs to stop process, you may try
creating your own "close form" exception. Throw the exception, catch it
in the up the line.

The better way would be to return false from your function and then
check it up the line, if it returns false, don't continue to process.

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top