Dim strData As String Try strData = serialport.ReadTo(Chr(&HA)) If (strData.Length > 0) Then MsgBox("Drive returned data before initial LF:" & _ vbNewLine & strData) 'This should be empty. always. End If Catch ex As Exception MsgBox("Coud not read to initial LF: " & vbNewLine & ex.Message) End Try ' Now read and trim the CR LF from the remaining data. strData = serialport.ReadExisting() If (strData.Length > 0) Then Try strData = strData.Substring(0, strData.Length - 2) Catch ex As Exception MsgBox("Serial data out of sync." & vbNewLine & vbNewLine _ & strData) End Try End If Return strData
MessageBox
ReadTo
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)