mcguirepm
12-21-2004, 12:15 PM
I'm amusing VB.Net to control various functions in Visual Manufacturing, an MRP system. What I need to find out is how do I capture any errors that my occur. For instance, I am using the following code to open a spcific work order, but how do I capture if the outside application throws an error that the Workorder was not found?
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim retval As MsgBoxResult
Dim MyAppID As Integer
On Error GoTo ERRRUNNING
' Run VisMfg.
MyAppID = Shell("V:\VMMFGWIN.EXE", AppWinStyle.NormalFocus)
AppActivate(MyAppID) ' Activate VisMfg
'% = Alt and ^ = Ctrl
SendKeys.SendWait(TextBox1.Text)
SendKeys.SendWait(Chr(9)) 'tab
SendKeys.SendWait(TextBox2.Text)
SendKeys.SendWait("%O")
'====
'this is where I need to add the error checking
'====
Exit Sub
ERRRUNNING:
retval = MsgBox("The Manufacturing Window is already open.", MsgBoxStyle.OKOnly, "VM Mfg Win")
AppActivate("Manufacturing Window(tm)") ' Activate VisMfg
SendKeys.SendWait("%F")
SendKeys.SendWait("O")
Resume Next
End Sub
Any insight would be greatfully appreciated. :)
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim retval As MsgBoxResult
Dim MyAppID As Integer
On Error GoTo ERRRUNNING
' Run VisMfg.
MyAppID = Shell("V:\VMMFGWIN.EXE", AppWinStyle.NormalFocus)
AppActivate(MyAppID) ' Activate VisMfg
'% = Alt and ^ = Ctrl
SendKeys.SendWait(TextBox1.Text)
SendKeys.SendWait(Chr(9)) 'tab
SendKeys.SendWait(TextBox2.Text)
SendKeys.SendWait("%O")
'====
'this is where I need to add the error checking
'====
Exit Sub
ERRRUNNING:
retval = MsgBox("The Manufacturing Window is already open.", MsgBoxStyle.OKOnly, "VM Mfg Win")
AppActivate("Manufacturing Window(tm)") ' Activate VisMfg
SendKeys.SendWait("%F")
SendKeys.SendWait("O")
Resume Next
End Sub
Any insight would be greatfully appreciated. :)