Hi buddies,
I'm working on a MDI application. I'm gettting this exception message "Exception has been thrown by the target of an invocation". It appears when I try to call a function or procedure in child form which is active using toolbar button. Below is the code in MDI frorm:
Private Sub tBar_mdi_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles tBar_mdi.ButtonClick
Call Me.ToolBarButtonProc(tBar_mdi.Buttons.IndexOf(e.Button))
End Sub
Public Sub ToolBarButtonProc(ByVal IndexNo As Integer)
Dim FRMNAME = ActiveMdiChild
If Me.ActiveMdiChild Is Nothing Then
Exit Sub
End If
Try
If IndexNo = 0 Then
Call FRMNAME.cmdAdd()
ElseIf IndexNo = 1 Then
Call FRMNAME.cmdModify()
ElseIf IndexNo = 2 Then
Call FRMNAME.cmdView()
ElseIf IndexNo = 3 Then
Call FRMNAME.cmdDelete()
ElseIf IndexNo = 4 Then
Call FRMNAME.cmdPrint()
ElseIf IndexNo = 5 Then
Call FRMNAME.cmdSave()
ElseIf IndexNo = 6 Then
Call FRMNAME.cmdCancel()
ElseIf IndexNo = 7 Then
Call FRMNAME.cmdRead()
ElseIf IndexNo = 8 Then
Call FRMNAME.cmdWrite()
ElseIf IndexNo = 9 Then
Me.Close()
End If
Catch Exp As Exception
MsgBox(Exp.Message, MsgBoxStyle.Information, "Index Error")
End Try
Exit Sub
End Sub
Please guide me why I'm getting this error message and correct me since I'm newbie this forum as well as in Vb.net. It would be kind enough if they is sample code or comments from you ppl.
Looking forward for your prompt reply.
Thnx n rgds,
jpdbay
I'm working on a MDI application. I'm gettting this exception message "Exception has been thrown by the target of an invocation". It appears when I try to call a function or procedure in child form which is active using toolbar button. Below is the code in MDI frorm:
Private Sub tBar_mdi_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles tBar_mdi.ButtonClick
Call Me.ToolBarButtonProc(tBar_mdi.Buttons.IndexOf(e.Button))
End Sub
Public Sub ToolBarButtonProc(ByVal IndexNo As Integer)
Dim FRMNAME = ActiveMdiChild
If Me.ActiveMdiChild Is Nothing Then
Exit Sub
End If
Try
If IndexNo = 0 Then
Call FRMNAME.cmdAdd()
ElseIf IndexNo = 1 Then
Call FRMNAME.cmdModify()
ElseIf IndexNo = 2 Then
Call FRMNAME.cmdView()
ElseIf IndexNo = 3 Then
Call FRMNAME.cmdDelete()
ElseIf IndexNo = 4 Then
Call FRMNAME.cmdPrint()
ElseIf IndexNo = 5 Then
Call FRMNAME.cmdSave()
ElseIf IndexNo = 6 Then
Call FRMNAME.cmdCancel()
ElseIf IndexNo = 7 Then
Call FRMNAME.cmdRead()
ElseIf IndexNo = 8 Then
Call FRMNAME.cmdWrite()
ElseIf IndexNo = 9 Then
Me.Close()
End If
Catch Exp As Exception
MsgBox(Exp.Message, MsgBoxStyle.Information, "Index Error")
End Try
Exit Sub
End Sub
Please guide me why I'm getting this error message and correct me since I'm newbie this forum as well as in Vb.net. It would be kind enough if they is sample code or comments from you ppl.
Looking forward for your prompt reply.
Thnx n rgds,
jpdbay