Private Sub srlPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles srlPort.DataReceived Dim intIndex As Integer Dim strRxdCRC As String Dim strHexData As String Dim strCRCCode As String = "" Dim intNumBytes As Integer = srlPort.BytesToRead Dim bytCharData(intNumBytes - 1) As Byte Try '//Disable buffer timeout interrupt tmrBufferDelay.Enabled = False blnReceived = True strRxd = "" srlPort.Read(bytCharData, 0, intNumBytes) For intIndex = 0 To intNumBytes - 1 strRxd = strRxd & Chr(bytCharData(intIndex)) Next intIndex If strRxd = "" Then Exit Sub srlPort.ReceivedBytesThreshold = CType(txtBufferCount.Text, Integer) '//Receive light - ON With lblRxdIndicator .BackColor = Color.Red .Refresh() End With '//Transmit light - OFF With lblTXDIndicator .BackColor = Color.Black .Refresh() End With '//Enable loop send timer If hsbRepeatTime.Value <> 0 Then tmrLoopDelay.Enabled = True End If lblStatus.Text = " Receiving. . ." '//16 bit CRC If mnuCRC16.Checked = True Then Dim intDataLength As Integer = strRxd.Length '//Store received CRC strRxdCRC = strRxd.Substring((intDataLength - 2), 2) '//All but CRC strHexData = strRxd.Substring(0, (intDataLength - 2)) Call CRC16(strHexData, strCRCCode) If strRxdCRC <> strCRCCode Then lblCRC.ForeColor = Color.Red Else lblCRC.ForeColor = Color.Black End If Call DisplayUpdate() '//32 bit CRC ElseIf mnuCRC32.Checked = True Then 'hexdata = Left(hexdata, Len(hexdata) - 8) 'Call CRC32(hexdata, crccode) 'If rxdcrc <> crccode Then ' lblCRC(1).ForeColor = vbRed 'Else ' lblCRC(1).ForeColor = vbBlack 'End If Else Call DisplayUpdate() End If Catch ex As Exception Call MainErrTrap() End Try End Sub 'srlPort_DataReceived