Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15042

[RESOLVED] Hex value to Byte of Hex value

$
0
0
Hello,

Can someone please help me with this:
I have the Hex value as &H6021FA64 (Note: I don't want to declare my hex value as a string)

and I need them as a byte of hex value

Dim frame(3) as byte
frame(0) = 64
frame(1) = FA
frame(2) = 21
frame(3) = 60

so that I can pass them as a frame of byte of hex value in this CRC calculation function:
Code:

    Function calcrc(ByVal data() As Byte) As Integer
            Dim crc As Integer = 0
            Dim i, j As Integer
            Dim d As Integer
       
            For i = 0 To data.Length - 1
                d = data(i)
                crc = crc Xor (d << 8)
                For j = 0 To 7
                    If ((crc And &H8000) <> 0) Then
                        crc = (crc << 1) Xor &H1021
                    Else
                        crc = (crc << 1)
                    End If
                Next
            Next
            calcrc = crc And &HFFFF
    End Function

How am I supposed to do this?
Thanks in advance.

What I have tried is:
&H6021FA64 Mod &H100
(&H6021FA64 \ &H100) Mod &H100
(&H6021FA64 \ &H10000) Mod &H100
&H6021FA64 \ &H1000000

But I am getting these bytes as Integer value 100, 250, 33, 96 respectively.

Viewing all articles
Browse latest Browse all 15042

Trending Articles