Could someone help me with this one?
I have developed a small application. It has a MDIParent form on which the other childforms are displayed. I have a Panel on the MDIParent on which there are buttons to call up the MDIChild forms. Now my issue is, when anyone of the buttons on the MDIParents form Panel are clicked, it should check if another Childform is display, if it is then it (the active childform is closed) and the new form will be displayed. This part is working fine from the code below. However, when there are no active MDIChild form on the MDIParent form and if the button is clicked, the 'Else' part of my code below is executed. This generates the error as 'Object reference not set to an instance of an object'. So what is wrong with my code below? Please help me get this one done. :confused:
Thanking you in advance..
Private Sub btnExecutive_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExecutive.Click Dim MDIChildForm As New frmExecutiveInfo MDIChildForm.MdiParent = Me Try If MDIChildForm.MdiParent.ActiveMdiChild.Visible = True Then MDIChildForm.MdiParent.ActiveMdiChild.Close() MDIChildForm.Show() Else MDIChildForm.Show() End If Catch ex As Exception MsgBox(ex.Message) End Try End Sub
Edited by kipslem: n/a