Question : Calculating a CRC-16

I have included a CRC routine however i would like to see the return value not in an integer format but in hex how can i convert?


1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
Public message_size_Upload(42) As Byte
    Public crc_value = 0
    Public bitvalue As Byte()
    Public bitcrc As Byte()
    Public Const POLY As Integer = &H8005
    Public len_upload As String = 80
    Public msg_size_Upload As Byte = len_upload

    Function CRC_Check_Table_Upload(ByVal msg_size_Upload As Integer) As Integer
        Dim i As Integer
        Dim j As Integer
        Dim msg As Integer

        crc_value = 0
        message_size_Upload(0) = 97
        message_size_Upload(1) = 140
        message_size_Upload(2) = 105
        message_size_Upload(3) = 188
        message_size_Upload(4) = 51
        message_size_Upload(5) = 79
        message_size_Upload(6) = 99
        message_size_Upload(7) = 92
        message_size_Upload(8) = 64
        message_size_Upload(9) = 162
        message_size_Upload(10) = 19
        message_size_Upload(11) = 109
        message_size_Upload(12) = 76
        message_size_Upload(12) = 48
        message_size_Upload(14) = 48
        message_size_Upload(15) = 49
        message_size_Upload(16) = 55
        message_size_Upload(17) = 57
        message_size_Upload(18) = 6
        message_size_Upload(19) = 76
        message_size_Upload(20) = 48
        message_size_Upload(21) = 48
        message_size_Upload(22) = 49
        message_size_Upload(23) = 55
        message_size_Upload(24) = 57
        message_size_Upload(25) = 56
        message_size_Upload(26) = 49
        message_size_Upload(27) = 51
        message_size_Upload(28) = 69
        message_size_Upload(29) = 69
        message_size_Upload(30) = 54
        message_size_Upload(31) = 129
        message_size_Upload(32) = 16
        message_size_Upload(33) = 89
        message_size_Upload(34) = 62
        message_size_Upload(35) = 230
        message_size_Upload(36) = 1
        message_size_Upload(37) = 213
        message_size_Upload(38) = 107
        message_size_Upload(39) = 21
        message_size_Upload(40) = 82


        'loops through message of byte
        For i = 0 To msg_size_Upload - 1
            msg = (message_size_Upload(40))
            msg = (msg << 8) And &HFFFF
            'loop through the message of bits
            For j = 0 To 7
                If ((msg Xor crc_value) >> 15) > 0 Then
                    'shifts the CRC bit values and compare with POLY
                    crc_value = ((crc_value << 1) Xor POLY) And &HFFFF
                Else
                    crc_value <<= 1
                    'shift the CRC bit values
                    crc_value = (crc_value) And &HFFFF
                End If
                msg <<= 1
                msg = (msg) And &HFFFF
            Next j
        Next i
        'returns the CRC value in decimal (number) format
        bitcrc = BitConverter.GetBytes(crc_value)
        Return (crc_value Xor 0)
    End Function

Answer : Calculating a CRC-16

Try something like this:
1:
BitConverter.ToString(bitcrc)
Random Solutions  
 
programming4us programming4us