'frmMain
Dim frmTest as form 'modular variable
Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
Select Case ToolBar1.Buttons.IndexOf(e.Button)
Case 0
'show frmKandles
If FormLoaded("frmKandles") Then
frmTest.Activate()
Else
frmTest = New frmKandles()
frmTest.MdiParent = Me
frmTest.Show()
End If
Case 1
'show frmSummary
If FormLoaded("frmSummary") Then
frmTest.Activate()
Else
frmTest = New frmSummary()
frmTest.MdiParent = Me
frmTest.Show()
End If
Case 2
'show frmAbout
If FormLoaded("frmAbout") Then
frmTest.Activate()
Else
frmTest = New frmAbout()
frmTest.MdiParent = Me
frmTest.Show()
End If
End Select
End Sub
Public Function FormLoaded(ByVal strName As String) As Boolean
'check to see if form is loaded
For Each frmTest In Me.MdiChildren
If frmTest.Name = strName Then
Return True
End If
Next
End Function
Private Sub frmMain_MdiChildActivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.MdiChildActivate
'work to be done
If FormLoaded("frmSummary") Then
frmTest.Activate()
End If
End Sub
'code in child form frmSummary
Private Sub frmSummary_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
MessageBox.Show("hey 2")
End Sub