hi,

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,
zawpai

Recommended Answers

All 7 Replies

why don't you try to disable all timer before you unload the form

use End.
in any event

End

Hi AUGXIS & Jx,

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.

Thanks,
zawpai

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,
zawpai

hmm.. im confused. can u tell more about the problem?

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
Loop
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,
zawpai

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.