Closing a MDI Child from the MDI parent throws an exception

G

Guest

Hello:

In the closing event of the MDI Parent, I have the following routine:

While Me.MdiChildren.Length > 0
liCounter = Me.MdiChildren.Length
Me.MdiChildren(liCounter - 1).Close()
End While

When I do have a MI Child, the .Close statement throws an exception, "Object
reference not set to an instance of an object".

What am I doing wrong?

Venki
 
C

C-Services Holland b.v.

vvenk said:
Hello:

In the closing event of the MDI Parent, I have the following routine:

While Me.MdiChildren.Length > 0
liCounter = Me.MdiChildren.Length
Me.MdiChildren(liCounter - 1).Close()
End While

When I do have a MI Child, the .Close statement throws an exception, "Object
reference not set to an instance of an object".

What am I doing wrong?

Venki

Try changing this line:
Me.MdiChildren(liCounter - 1).Close()
to
Me.MdiChildren(0).Close()
 
G

Guest

Eric:

It raises the same exception, "Run-time exception thrown :
System.NullReferenceException - Object reference not set to an instance of an
object."

I am stumped!

Venki
 
G

Guest

Eric:

I see the following sequence of events when I close the MDIParent Window:

1. It closes the MDI Child Frm, triggers the closing event of the MDIChild
form.
2. Then it triggers the MDI Parent's closing event. But Me.MIDChildren.Count
is still 1, even though the MDI Child form has already been closed.
3. This raised the exception.

Any more ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top