Vb校验和算法
我需要对下边一组数进行校验和的算法,算法是单字节相加,然后得到的结果取反+1,请问怎么计算呢?
需要校验和数据:A9 01(为01-16之间的数字) 01(为01-16之间的数字)00 00 00 00 00 00 00 00 00 00 00 00
[解决办法]
Private Sub Command1_Click() Dim a(14) As Byte, x As Integer, i As Integer a(1) = 1 a(2) = 1 For i = 1 To 14 x = x + a(i) Next x = x And 255 x = Not x + 1 End Sub
[解决办法]
Private Sub Command1_Click() Dim a(14) As Byte, x As Integer, i As Integer a(0) = &HA9 a(1) = &H16 a(2) = &H16 For i = 0 To 14 x = x + a(i) Next x = x And 255 x = Not x - 1 Dim aa As String aa = Right(Hex(x), 2)End Sub