我这段程序哪里有问题吗?收回的数据根发送的数据总对不上
Private Sub MSComm1_OnComm()
Dim receivedata As Byte
Select Case MSComm1.CommEvent '判断通信事件
Case comEvReceive '收到rthreshold个字节产生的接收事件
receivedata = MSComm1.Input(0)
If HeadOk = False Then
If receivedata = &HFF Then
If LastTimeisFF = True Then
NumberofFF = NumberofFF + 1
If NumberofFF > 2 Then
HeadOk = True
NumberofFF = 0
receivenumber = 0
MSComm1.InBufferCount = 0
End If
Else
NumberofFF = 1
LastTimeisFF = True
End If
End If
Else '已经收到3个FF 接收数据
receivebyte(receivenumber) = receivedata
If receivenumber = 5 Then
DataCount = receivedata + 2
ElseIf receivenumber > 5 Then
DataCount = DataCount - 1
If DataCount = 0 Then
receiveok = True
If Timer1.Enabled = True Then
Timer1.Enabled = False
Timer1.Interval = 10
Timer1.Enabled = True
End If
If Timer3.Enabled = True Then
Timer3.Enabled = False
Timer3.Interval = 10
Timer3.Enabled = True
End If
HeadOk = False
End If
End If
receivenumber = receivenumber + 1
End If
End Select
End Sub