Re: Using Form_KeyPress to quit

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"Willister" <Willister@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:6382C860-4BEB-4D9E-990D-D6D2B93A99AA@xxxxxxxxxxxxx
While on the subject, A second problem Im gettting is when the form
loads I have 2 msg boxes pop up. When the game ends, thoose 2
msgboxes popup again, and I cant compile on my version of vb6 so im
not sure how it will affect the final version. heres the code.

As Rick noted, it's hard to tell exactly from the partial code posted. Your
routine does an "Unload Me" but the loop that that is in will continue to
run and any code after it will also run. Somewhere in that code you are
referencing the form or a control on the form. When you do that VB will
reload the form, run the Form_Load event again, and then continue. That
will leave you with the form loaded but not visible and the app won't end
correctly.

When you decide to unload you also need to use 'Exit Sub' and/or set a flag
that other code can check so as to be sure not to reference anything that
will cause the form to reload.

If you put a breakpoint in your Form_Load routine then when it happens the
second time you can use Ctrl-Shift-F8 to step out of the routine and you'll
be on the line of code immediately after whatever triggered it to reload
again.

--
Reply to the group so all can participate
VB.Net: "Fool me once..."

.



Relevant Pages

  • Re: Standard Conventions for UserForms
    ... <I normally use Unload me rather than Me.Hide in an event routine to close ... so that when you move on to the next line of the calling routine ... outside the UserForm. ... All coding conventions have this second point as their ultimate aim. ...
    (microsoft.public.word.vba.userforms)
  • Re: C source code for demonstration repeatable compressor is available
    ... that referencing a GNU licensed program is legally the same as ... supplying the code. ... So I can not reference that routine. ...
    (comp.compression)
  • Variable Storage
    ... clicks this they are prompted with a MsgBox (vbYesNo). ... 'Yes' then I want to unload the form and then reload it again - ...
    (microsoft.public.excel.programming)
  • Re: I finally found the wooden stake to drive through my programs still beating heart!
    ... Once I had executed my Unload procedure, the code following the Unload statement sometimes made reference to a control, which would apparently "randomly" restart my form! ... Unload routine, and put the following line of code just after every subroutine call that could eventually result in an Unload statement being executed: ... That timer was keeping my form from terminating, even though it was not actually executing any code at the time I was Unloading. ... A one-minute watchdog-like timer that runs a small diagnostic whenever it ticks, and if things don't appear to be proceeding normally, it resets the state machine back to an idle condition. ...
    (microsoft.public.vb.enterprise)
  • Re: [PATCH 3/3] - Add support for acpi_load_table/acpi_unload_table_id
    ... for use by removing it from the #ifdef ACPI_FUTURE_USAGE. ... The implementation of this new routine was almost a direct ... interfaces to dynamically load and unload SSDT ACPI tables. ... so that Linux doesn't diverge from the reference implementation. ...
    (Linux-Kernel)