Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculate Checksum VB 6

Status
Not open for further replies.

fabianuat

Programmer
Jan 4, 2007
4
0
0
US
Could I have some help calculating a checksum for receive data from a Video server?

The data is in Hex and the values and here is an example:
20 24 49 4C 30 31 37 38 37 39 CS
CS=Checksum

the cheksum is the 2's complement of the sum of the values.

If anyone have an algoritm or knows how to do it, please help me, thanks
 
How to do it - break the data down into bytes, and treat each byte as an int. Add them all together (total).

Checksum = 256 - (total % 256), which you will need to reduce to 1 byte.

Alternative - flip all the bits in total by a bitwise AND with xFF, then add 1.

That's the theory. How to do it in VB6, over to one of the experts...

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top