补充如下:Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As ) Handles SerialPort1.DataReceived
Dim i As UInteger = 0
Thread.Sleep(50) '根据字符数量及波特率计算延时 单位为ms
' intNum = 0
intNum = SerialPort1.BytesToRead
If intNum = 0 Then
Return
End If
ReDim rc(intNum)
For i = 0 To (intNum - 1)
rc(i) = SerialPort1.ReadByte 'strRec=SerialPort1.ReadLine
Next
If intNum > 4 Then
flag1 = 1 'StatusDefine.TwoEnum
' If SerialPort1.IsOpen Then SerialPort1.Close()
End If
End Sub