question about testing if my form is still open in my MDI form

I have an MDI. I open a form, then when the user clicks Accept, I do: myForm.Close

Then in my MDI parent form I need to check if the form is still open in which case I should do nothing. And if It s closed, I should create it and show it agin. so here is what I do:

To open the form from MDI I call: myChildForm.Show()

To close, I do in Accept_click event of myChildForm I call: me.close

in MDI parent form, to check if the child form is open I do:

If myMdiChildForm Is Nothing then

Instantiate new instance and show it

End if

The problem: Ny code doesn t execute the code: Instantiate new instance and show it

like if it doesn consider that myChildForm IS Nothing after I close it .

Any Idea pls

Thanks

[777 byte] By [R.Tutus] at [2007-12-25]
# 1

Hi

Try doing like this :

In parent MDI form add this code wherever it is required

--

Dim OldMDIChild As myMdiChildForm

If (OldMDIChild Is Nothing) Then

Dim NewMDIChild As New myMdiChildForm

NewMDIChild.MdiParent = Me

NewMDIChild.Show()

End If

--

Hope this works

SandyN at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2

That's because the child form is not nothing. The reference still exists, it just points to a disposed object.

Try using:

If myChildForm Is Nothing Then
'Create new instance
ElseIf myChildForm.IsDisposed Then
'Create new instance
End If

rkimble at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...