|
-
Mar 27th, 2000, 01:45 AM
#1
Thread Starter
Member
I am having problems unloading forms. I am currently running a parent form with several child forms and a few seperate forms. In the Form_Unload of the parent form, I am running the following block of code:
Private Sub Form_Unload(Cancel as Integer)
Dim frm as Form
For Each frm in Forms
Unload frm
Next frm
End Sub
When this is run, it makes it all the way through, then after the End Sub is executed, i get an illegal operation error.
VB5 caused an invalid page fault in
module KERNEL32.DLL at 014f:bff7926e.
I have been trying to get this thing to work now for several hours, and am out of things to try. Anyone have any suggestions?????
-
Mar 27th, 2000, 01:58 AM
#2
Fanatic Member
It's only a guess but, you are looping through all the forms and unloading them, so therefore is it trying to unload the mdi parent form again.
Try something like :
for each frm in forms
if frm.name <> "mdiParent" then unload frm
next frm
-
Mar 27th, 2000, 02:06 AM
#3
Thread Starter
Member
Thank you for your help, but I still got the same error. Anyone else have anything I can try?
-
Mar 27th, 2000, 03:21 AM
#4
Lively Member
Hello,
Here we go try this, I've never had no problems with it so hopefully you shouldn't either.
Code:
Dim x As Integer
For x = (Forms.Count - 1) To 0 Step -1
If TypeOf Forms(x) Is MDIForm Then
'//DO NOTHING
Else
Unload Forms(x)
End If
Next x
Hope it helps,
Desire.
-
Mar 27th, 2000, 03:30 AM
#5
Thread Starter
Member
Still no luck Desire. Thanks anyways. Can anyone else offer an opinion?
-
Mar 27th, 2000, 03:34 AM
#6
Lively Member
Hello,
Is your parent form a MDIForm of just a standard form?
Desire.
-
Mar 27th, 2000, 03:58 AM
#7
transcendental analytic
VB5 caused an invalid page fault in
module KERNEL32.DLL at 014f:bff7926e.
I have had the same kind of problem once, but I need to take a look at your project. Could you send it to me?
-
Mar 27th, 2000, 04:06 AM
#8
Thread Starter
Member
Thank you for all of your help. I have actually found the problem, but would like some input on this as well.
The problem was that I was Redimming a few arrays several times throughout the code. When it went to unload the form, I guess it had problems with releasing this memory. I got around it by:
Set Array = Nothing
Then I went on with:
For Each frm in Forms
Unload frm
Next frm
That worked great. I do not fully understand why it would have had a problem releasing those arrays. Could anyone comment on that?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|