Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Byte Array to a Signed Integer in VB6

Tags:

arrays

vb6

I am having trouble converting from a Byte Array to a Signed Integer in VB6. This would be simple to do with BitConverter in .NET but I'm not sure what to do with VB6. Thanks

like image 543
Questioner Avatar asked Jul 04 '26 17:07

Questioner


1 Answers

Unfortunately no built in function, you need to write one. Here is a quick sample to get you started.

Private Function BArrayToInt(ByRef bArray() As Byte) As Integer
    Dim iReturn As Integer
    Dim i As Integer

    For i = 0 To UBound(bArray) - LBound(bArray)
        iReturn = iReturn + bArray(i) * 2 ^ i
    Next i

    BArrayToInt = iReturn

End Function
like image 78
jac Avatar answered Jul 07 '26 05:07

jac



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!