I am having a problem when using a CWGPIB object in an ActiveX exe. I am not using a form so I have a reference to the object defined and instanced as follows:
Private WithEvents GPIBPort as CWGPIB
Set GPIBPort = New CWGPIB
I have two events defined as follows:
Private Sub GPIBPort_DataReady(ByVal taskNumber As Integer, data As Variant)
Dim ReturnVals() As String
GPIBData = data
ReturnVals() = Split(GPIBData, ",")
mvarValue = CDbl(ReturnVals(2))
ComServer.FireRecdEvent Key, CStr(data) & vbCrLf
ComServer.FireDeviceEvent Key, KEITHLEY_VALUE
If GPIBSendReplyToPLC Then mvarPort_PortEvent Key, CStr(data)
GPIBBusy = False
GPIBSendReplyToPLC = False
End Sub
' If there is an error, put up a message box with the error message
Private Sub GPIBPort_OnError(ByVal ErrorCode As Long, ByVal ErrMsg As String)
'set error codes here
mvarErrCode = ErrorCode
mvarErrDesc = ErrMsg
ComServer.FireRecdEvent Key, "GPIB Error Event, Error Code-" & CStr(ErrorCode) & ", Desc-" & ErrMsg & vbCrLf
ComServer.FireDeviceEvent Key, KEITHLEY_ERROR
GPIBBusy = False
GPIBSendReplyToPLC = False
End Sub
Both events do some processing and then fire two events out from my ActiveX exe to its clients.
The GPIBPort events fire predictably whenever there is a reading or an error. My events that are fired out to my clients fom the GPIBPort_DataReady event work perfectly, but my events fired from the GPIBPort_OnError event are never received by my clients. When I debug the firing of my events from either of the GPIBPort events they do the same thing as far as I can see.
Any idea would be greatly appreciated!
Dave