I am trying to figure out a CRC check for a serial controlled device. I have an example, when i send this example to the device, it responds correctly.

This is the complete serial string wich the device responds to:

Code:
\x00\x17\x3d\x30\x32\x32\x30\x39\x39\x30\x30\x30\x30\x30\x30\x30\x30\x30\x37\x34\x30\x30\x30\x30\x30\x01\x28
(The last 2 bytes (\x01\x28) are the CRC outcomes).

Code:
This is my code:

Dim Send As String
Dim CRC1 As String
Dim CRC2 As String
Dim TEMP As String

Private Sub Command1_Click()

Send = &H0 & &H17 & "=" & "022" & "099" & "00" & "00" & "0000074" & "00000"

CRC1 = &H0
CRC2 = &H0
TEMP = &H0

For i = 1 To Len(Send)
    TEMP = CRC1
    CRC1 = CRC2 Xor Asc(Mid$(Send, i, 1))
    CRC2 = TEMP

Next i

Text1.Text = "CRC1= " & CRC1 & " / CRC2= " & CRC2

End Sub
The output should be: CRC1 = 1 (decimal) and CRC2 = 40 (decimal) But i am getting 51/60.

I think is has somnething to do with datatypes.

This is the original CRC formule from the device:

Code:
Set <CRC1> and <CRC2> to zero.
For every <CHAR> in <MSG> do
<TEMP> = <CRC1>
<CRC1> = <CRC2> XOR <CHAR>
<CRC2> = <TEMP>
Thanks in advance!