Function CRC16(strData) 'Based on http://www.di-mgt.com.au/src/basCRC16.txt by David Ireland Dim lngCRC, intCount, intPointer, intCharacter, intShifted, strTable, lngTable(255) strTable = "0000C0C1C1810140C30103C00280C241C60106C00780C7410500C5C1C4810440" _ & "CC010CC00D80CD410F00CFC1CE810E400A00CAC1CB810B40C90109C00880C841" _ & "D80118C01980D9411B00DBC1DA811A401E00DEC1DF811F40DD011DC01C80DC41" _ & "1400D4C1D5811540D70117C01680D641D20112C01380D3411100D1C1D0811040" _ & "F00130C03180F1413300F3C1F28132403600F6C1F7813740F50135C03480F441" _ & "3C00FCC1FD813D40FF013FC03E80FE41FA013AC03B80FB413900F9C1F8813840" _ & "2800E8C1E9812940EB012BC02A80EA41EE012EC02F80EF412D00EDC1EC812C40" _ & "E40124C02580E5412700E7C1E68126402200E2C1E3812340E10121C02080E041" _ & "A00160C06180A1416300A3C1A28162406600A6C1A7816740A50165C06480A441" _ & "6C00ACC1AD816D40AF016FC06E80AE41AA016AC06B80AB416900A9C1A8816840" _ & "7800B8C1B9817940BB017BC07A80BA41BE017EC07F80BF417D00BDC1BC817C40" _ & "B40174C07580B5417700B7C1B68176407200B2C1B3817340B10171C07080B041" _ & "500090C191815140930153C052809241960156C057809741550095C194815440" _ & "9C015CC05D809D415F009FC19E815E405A009AC19B815B40990159C058809841" _ & "880148C0498089414B008BC18A814A404E008EC18F814F408D014DC04C808C41" _ & "440084C185814540870147C046808641820142C043808341410081C180814040" For intCount = 0 To 255 lngTable(intCount) = CLng("&H" & Mid(strTable, intCount * 4 + 1, 4)) Next lngCRC = 0 For intCount = 1 To Len(strData) intCharacter = Asc(Mid(strData, intCount, 1)) intPointer = (lngCRC And &HFF) Xor intCharacter intShifted = (lngCRC And &H7FFF) \ 256 If (lngCRC And &H8000) <> 0 Then intShifted = intShifted Or &H80 End If lngCRC = intShifted Xor lngTable(intPointer) Next CRC16 = Right("0000" & Hex(lngCRC), 4) End Function