接收到的数据如何处理才能按格式显示?
我用串口控件接收一串长度未知的数据 例如
0B FF 02 00 F4 0B FF 07 00 20 00 00 00 21 AE 0B FF 07 00 20 00 00 00 23 AC 0B FF 07 00 20 00 00 00 26 A9 0B FF 07 00 20 00 00 00 22 AD 0B FF 07 00 20 00 00 00 25 AA 0B FF 07 00 20 00 00 00 1E B1 0B FF 07 00 20 00 00 00 0D C2 0B FF 07 00 20 00 00 00 11 BE 0B FF 07 00 20 00 00 00 0C C3 0B FF 07 00 20 00 00 00 0E C1 0B FF 07 00 20 00 00 00 1F B0 0B FF 07 00 20 00 00 00 0F C0 ………………
我现在是一个字节一个字节接收的
要判断接受到的前5个是不是0B FF 02 00 F4
如果是 说明通信正常
然后取后面的那些数据
比如0B FF 07 00 20 00 00 00 21 AE
后面每10个算作一条数据记录
把这10个字节中的从“20”开始起的5个字节显示到list控件上
即显示20 00 00 00 21
后面的也是依次类推
每条数据都是只显示这样的5个字节
list控件里每行显示一条
这个怎么实现?????????
Private Sub MSComm1_OnComm()
Dim a() As Byte '接收数据字节数组
Dim data(32) As Integer
Dim ind As Long
Dim str As String
Select Case
Case comEvSend
MSComm1.InputLen = 0
Case comEvReceive
While MSComm1.InBufferCount > 0
a = MSComm1.Input
data(ind) = CInt(a(0))
If data(ind) = &H64 Then
If data(0) = &HB And data(1) = &HFF And data(2) = &H2 And data(3) = &H0 And data(4) = &HF4 Then
End If
End If
str = str & " " & Format(Hex(a(0)), "00") & " "
Wend
List1.AddItem (str)
List1.Selected(List1.ListCount - 1) = True
End Select
End Sub
我现在这样做总是会在第一行显示前5个:0B FF 02 00 F4 ,我现在就是不想显示这5个。如何修改才能实现呢?