Hi group! I need to rewrite a relatively simple CRC16 routine from C to VB6=2E This should not be a problem if I wasn't a C virgin=2E I just can't get the hang of C syntax=2E Could someone please have a look at it and point out what I am doing wrong=2E There are two routines, one inits the table and the other performs the actual CRC calc=2E I took a stab at the init part, but since i expect the table to be 16 bit, I'm not very satisfied with the results=2E This is what I get: CRC(0) =3D FEF1F CRC(1) =3D EEF1F CRC(2) =3D DEF1F CRC(3) =3D CEF1F CRC(4) =3D BEF1F CRC(5) =3D AEF1F CRC(6) =3D 9EF1F CRC(7) =3D 8EF1F =2E=2E=2E CRC(248) =3D F7EF1F CRC(249) =3D F6EF1F CRC(250) =3D F5EF1F CRC(251) =3D F4EF1F CRC(252) =3D F3EF1F CRC(253) =3D F2EF1F CRC(254) =3D F1EF1F CRC(255) =3D F0EF1F Here is the C code: // initialize the CRC16 table extern void InitCRC16( void ) { int i, j ; WORD crc ; for ( i =3D 0 ; i < 256 ; i +=3D 1 ) { for ( crc =3D i << 8 , j =3D 0 ; j < 8 ; j +=3D i ) crc =3D ( crc << 1 ) ^ ( ( crc & 0x8000 ) ? 0x1021 : 0 ) ; CRC16Table [ i ] =3D crc ; } } // calculate the CRC of a string pointed at by p extern WORD CalcCRC16 ( char * p ) { WORD CRC ; for ( CRC =3D 0xFFFF ; *p !=3D 0 ; p++ ) // for all chars of a string CRC =3D CRC16Table [ ( ( CRC >> 8 ) & 255 ) ] ^ ( CRC << 8 ) ^ *p ; return CRC ; } And my feeble VB attempt: Option Explicit Dim C16(255) As Long Sub CRC_Init() Dim i As Long, j As Long Dim crc As Long For i =3D 0 To 255 crc =3D i * 256 For j =3D 0 To 7 If crc >=3D &H8000 Then crc =3D (crc * 2) Xor &H1021 Else crc =3D (crc * 2) Xor 0 End If Next j C16(i) =3D crc Next i End Sub TIA, Hugo -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.