I have a class with an event. I am trying to raise the event and have another project in the same solution capture that event. Here is the code:
The class with the event
The code that calls the class with event
The code that captures the event
Please note that each of these items are in seprate projects in the same solution.
I have stepped throught the project and the RaiseEvents line in the DispatchInfo class is executing, but the event handler in the last project is not, and I don't know why.
Any help is apprecated.
Thanks,
Branden
The class with the event
Code:
Public Class DispatchInfo
Public Event newDispatch(ByVal dispInfo As DataTable)
Public Sub recieveDispatch(ByVal disp As DataTable)
RaiseEvent newDispatch(disp)
End Sub
End Class
The code that calls the class with event
Code:
Public Sub sendDispatch(ByVal dt As DataTable, ByRef lstlog As ListBox)
lstLog.Items.Add("Sending data on Call # " & dt.Rows(0)("CallNum"))
Dim x As New DispatchInfo.DispatchInfo
x.recieveDispatch(dt)
lstLog.Items.Add("Send Completed")
lstLog.Items.Add("Waiting for CAD.......")
End Sub
The code that captures the event
Code:
Private WithEvents dispObj As New DispatchInfoObject.DispatchInfo
Private Sub dispObj_newDispatch() Handles dispObj.newDispatch
If dispInfo.Rows.Count > 0 Then
Dim row As DataRow = dispInfo.Rows(0)
Dim dispatchInfoArray As String
If Not IsDBNull(row(0)) Then
dispatchInfoArray = row(0) & "|"
Else
dispatchInfoArray = " |"
End If
If Not IsDBNull(row(1)) Then
dispatchInfoArray = dispatchInfoArray & row(1) & "|"
Else
dispatchInfoArray = dispatchInfoArray & " |"
End If
If Not IsDBNull(row(2)) Then
dispatchInfoArray = dispatchInfoArray & row(2) & "|"
Else
dispatchInfoArray = dispatchInfoArray & " |"
End If
If Not IsDBNull(row(3)) Then
dispatchInfoArray = dispatchInfoArray & row(3) & "|"
Else
dispatchInfoArray = dispatchInfoArray & " |"
End If
If Not IsDBNull(row(4)) Then
dispatchInfoArray = dispatchInfoArray & row(4) & "|"
Else
dispatchInfoArray = dispatchInfoArray & " |"
End If
If Not IsDBNull(row(5)) Then
dispatchInfoArray = dispatchInfoArray & row(5) & "|"
Else
dispatchInfoArray = dispatchInfoArray & " |"
End If
If Not IsDBNull(row(6)) Then
dispatchInfoArray = dispatchInfoArray & row(6) & "|"
Else
dispatchInfoArray = dispatchInfoArray & " |"
End If
If Not IsDBNull(row(7)) Then
dispatchInfoArray = dispatchInfoArray & row(7) & "|"
Else
dispatchInfoArray = dispatchInfoArray & " |"
End If
If Not IsDBNull(row(8)) Then
dispatchInfoArray = dispatchInfoArray & row(8) & "|"
Else
dispatchInfoArray = dispatchInfoArray & " |"
End If
If Not IsDBNull(row(9)) Then
dispatchInfoArray = dispatchInfoArray & row(9) & "|"
Else
dispatchInfoArray = dispatchInfoArray & " |"
End If
If Not IsDBNull(row(10)) Then
dispatchInfoArray = dispatchInfoArray & row(10) & "|"
Else
dispatchInfoArray = dispatchInfoArray & " |"
End If
If Not IsDBNull(row(11)) Then
dispatchInfoArray = dispatchInfoArray & row(11) & "|"
Else
dispatchInfoArray = dispatchInfoArray & " |"
End If
If Not IsDBNull(row(12)) Then
dispatchInfoArray = dispatchInfoArray & row(12)
Else
dispatchInfoArray = dispatchInfoArray & " "
End If
If SocketTCP.Connected Then
SocketTCP.Send(dispatchInfoArray)
End If
End If
End Sub
Please note that each of these items are in seprate projects in the same solution.
I have stepped throught the project and the RaiseEvents line in the DispatchInfo class is executing, but the event handler in the last project is not, and I don't know why.
Any help is apprecated.
Thanks,
Branden