B4R Code Snippet hex to int

found, that sometimes it's easyer, to knit it up...:)

private Sub intFromHex(b1() As Byte)As Int
Dim in As Int
'send( JoinStrings(Array As String("b1 :", bc.StringFromBytes(b1))) ) 'test

For i = 0 To b1.Length - 1
Dim m As Double = Power(16,b1.Length-1-i) ' multiplikator
If b1(i)>60 Then
b1(i) = b1(i) - 55
in = in + b1(i)*m
b1(i) = b1(i) - 48
in = in + b1(i)*m
End If
'send( JoinStrings(Array As String(" i: ", i," m: ", m)) ) 'test

'send( JoinStrings(Array As String("in :", in)) ) 'test
Return in
End Sub

... but be carefull, b1 is to be destructed...
Last edited:


Active Member
Licensed User
Longtime User
For 32 bit integers you need to use:

Convert Hexadecimal string 32 Bit to integer:
Dim i As Int = Bit.ParseLong(bc.StringFromBytes(b1), 32)

I know its an old post, but it is still a useful one.