发表于:2007-01-13 10:19:00
2楼
Private Function SumChk(Dats$) As String
Dim i&
Dim CHK&
For i = 1 To Len(Dats)
CHK = CHK + Asc(Mid(Dats, i, 1))
Next i
SumChk = Right(Hex$(CHK), 2)
End Function
比如例子:通讯协议
STX ,CMD ,ADDRESS, BYTES, ETX, SUM
02H, 30H, 31H,30H,46H,36H, 30H,34H, 03H, 37H,34H
和校验为:SUM=CMD+......+ETX;
30h+31h+30h+46h+36h+30h+34h+03h=74h;
Dats$为“3031304636303403”吗?可是返回的不是74啊,如何解释?
Dats$如何写,望指教!