首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

Vb校验和算法解决方法

2012-02-19 
Vb校验和算法我需要对下边一组数进行校验和的算法,算法是单字节相加,然后得到的结果取反+1,请问怎么计算呢

Vb校验和算法
我需要对下边一组数进行校验和的算法,算法是单字节相加,然后得到的结果取反+1,请问怎么计算呢?
需要校验和数据:A9 01(为01-16之间的数字) 01(为01-16之间的数字)00 00 00 00 00 00 00 00 00 00 00 00

[解决办法]

VB code
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
[解决办法]
VB code
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 

热点排行