Design-time only means while you are writing code, etc. Run-time is when you run it, whether that is in VB or compiled.

The answer to your question is that you cannot stop the code and then have something happen - you need to close it properly (the same way you would when it is compiled), so that the code to tidy up has a chance to run.


Note that Form_QueryUnload is actually the wrong place for the code, it should be in Form_Unload instead. There is an explanation of why in the article How should I close my form/program/class? from our Classic VB FAQs