Could anyone please explain to me about the following question?
Although I do 'unload me', but it can't be closed immediately and some parts of that form is still processing. Eg; my project has many timers and other processing sequences.

I really don't know how to solve it because I can't trace in one line.

Best Regards,


As AUGXIS told, I need to disable all the timer before I colse the form. If not, the form will be called again because one process looping is doing in a timer while closing the form. That why the error will come out.
Jx, I don't want to put 'End' function in every event because I don't want to terminate all my application.

I will try to solve that problem.


a suggestion, Why not Check if the control is a timer? by that way you can disable each timer in your form

For Each ctl In Me.Controls
    If TypeOf ctl Is Timer Then
    ctl.Enabled = False
    End If
Next ctl

hi cometburn,

That is a good way to close timers control.
Let's me ask you one more question. Could I check any process is still doing while closing the main Form. Eg: one function including with 'DoEvents'.
Above function processing will call the main form again although the Form do 'Unload'. In this condition, how should I solve it?

Can you give me some suggestions?

Best Regards,

Hi cometburn,

The ideal is the same as timer control.
Eg: I have a functin that inclues one do while looping. When I close the Form, but the processing for do while looping is still continuous. Then, it will show an error message and the application will be end automatically.

Private Sub Processing()
Do While (CloseForm = False)
Form1.Label1.Visible = True
End Sub

This is just a sample one. You will see the looping that are using the Form name. How can slove that situation?

Best Regards,

This article has been dead for over six months. Start a new discussion instead.