Link to home
Start Free TrialLog in
Avatar of LeighWardle
LeighWardleFlag for Australia

asked on

VB6 - why is Sub MDIForm_Load() being called when I terminate my program?

Hi,

I am using some code (snippet below) from this webpage (see below "Avoid the End Statement"):
http://www.pgacon.com/visualbasic.htm

But I have been debugging this code, and I have just noticed that the Sub MDIForm_Load() is being called.
That doesn't seem right to me.

Regards,
Leigh
Public Sub TerminateProgram()
 
Static Unloading As Boolean
Dim idx As Integer
 
If Unloading Then Exit Sub
Unloading = True
 
For idx = Forms.Count - 1 to 0 Step -1
    Unload Forms(idx)
Next idx
 
Unloading = False
 
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of LeighWardle

ASKER

Hi Graham,  I made some changes to my code, then couldn't reproduce the problem.  So it's not an issue, hopefully.  Thanks for your help. Regards, Leigh