I an new to using VB.net and I am using the serialport class that Microsoft has kindly created for VB.net 2005.
I am trapping the received event and reading the byte in sucessfully, but when I try to access the main form richtextbox to append the data i get an
"A first chance exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll" exception.
If I call the function from a button on the same form, then this doesn't happen.
Any help or guidance would be greatly appreciated.
Richard
I am trapping the received event and reading the byte in sucessfully, but when I try to access the main form richtextbox to append the data i get an
"A first chance exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll" exception.
If I call the function from a button on the same form, then this doesn't happen.
VB.NET:
Public WithEvents MyEvent As System.IO.Ports.SerialPort
Public Sub MyEvent_DoRx(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) _
Handles SerialPort1.DataReceived
Dim MyByteIn As String
MyByteIn = SerialPort1.ReadExisting
MsgBox("data received: " & MyByteIn)
DoAppendDebugText(MyByteIn)
End Sub
Public Sub DoAppendDebugText(ByVal MyDebStr As String)
MsgBox(" passed Value : " & MyDebStr)
Me.MyDebugText.AppendText(MyDebStr)
End Sub
Any help or guidance would be greatly appreciated.
Richard