Hi,

I need to calculate the CRC code from the bytes below, by using the CRC CCiTT Kermit checksum.

This is the complete code of my program: (i am using VB6)

==================================================================================================== ============

Private Sub Command1_Click()

'increase sequence byte value

Label1.Caption = Val(Label1.Caption) + 1

'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

'begin of CRC calculation

DataCRC1 = Chr$(bytcommand1) + Chr$(bytcommand2) + Chr$(bytcommand3) + Chr$(bytcommand4) + Chr$(bytcommand5) + Chr$(bytcommand6) + Chr$(bytcommand7)

'Step 1: CRC calculation for every byte of datastring (DataCRC1)

For i = 0 To 255

CRC = i

For J = 1 To 8

If (CRC And 1) = 1 Then

CRC = Fix(CRC / 2) Xor 33800

Else

CRC = Fix(CRC / 2)

End If

Next J

CRCT(i) = CRC

Next i

'Step 2: CRC calculation for all data from datastring (DataCRC1)

CRC = 0

For i = 1 To Len(DataCRC1)

HB1 = Fix(CRC / 256)

LB1 = CRC - (256 * HB1)

CRC = CRCT(LB1 Xor Asc(Mid$(DataCRC1, i, 1))) Xor HB1

Next i

HB1 = Fix(CRC / 256): cc1hb1 = Hex(HB1): If Len(cc1hb1) = 1 Then cc1hb1 = "0" & cc1hb1

LB1 = CRC - (256 * HB1): cc1lb1 = Hex(LB1): If Len(cc1lb1) = 1 Then cc1lb1 = "0" & cc1lb1

'End CRC calculation

'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +

On Error GoTo SendError

If MSComm1.PortOpen = True Then MSComm1.PortOpen = False

MSComm1.Settings = "19200,n,8,1"

MSComm1.CommPort = 1

Dim bytcommand(9) As Byte

'begin send data

bytcommand(0) = &H16 'SYN startbit

'CRC calculation FROM this part

bytcommand(1) = &H6

bytcommand(2) = &H9

bytcommand(3) = &HA

bytcommand(4) = &HF

bytcommand(5) = &HB

bytcommand(6) = Hex(Label1) 'sequence

bytcommand(7) = &H0

'CRC calculation TILL this part

bytcommand(8) = Hex(HB1) 'crc1

bytcommand(9) = Hex(LB1) 'crc1

'end send data

MSComm1.PortOpen = True

MSComm1.Output = bytcommand

MSComm1.PortOpen = False

Exit Sub

SendError: Exit Sub

End Sub

==================================================================================================== ===========

I am having the following bugs:

Sub or function not defined [CRCT]

and

I am not shure if i get the data for bytcommand 8 and 9 right [the CRC output]

Please help.