传入参数为:数组名,起始下标名, 计算元素数
Public Function checksum(array As Byte(), i_start As Integer, n As Integer) As Byte
If i_start < 0 Or n < 2 Then
MessageBox.Show("数组下标不能为负,或者求checksum个数不能小于2")
Return 0
Exit Function
End If
Dim result As Byte = array(i_start)
For i As Integer = i_start + 1 To i_start + n - 1 Step 1
result = result Xor array(i)
Next
Return result
End Function