Android Question What do i wrong with ByteConverter ?

Herbert32

Active Member
Licensed User
Longtime User
Hi,

hopefully someone can explain to me what i missunderstand :)

I tried following code-snippet:

B4X:
    Dim bc As ByteConverter
    Dim myBytes(5) As Byte
    
    myBytes(0) =0xFF
    myBytes(1) =0xDD
    myBytes(2) =0xFF
    myBytes(3) =0xFF
    myBytes(4) =0x00

    If myBytes(2) = bc.HexToBytes("FF") Then
        Log("WORKS !")
    Else
        Log("WHY NOT ?")
    End If

My logging-result always is 'WHY NOT ?'

what do i wrong?
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
bc.HexToBytes("FF")
returns an Bytearray, not just a single Byte.
In your case you need to do something like
B4X:
    If myBytes(2) = bc.HexToBytes("FF")(0) Then
        Log("WORKS !")
    Else
        Log("WHY NOT ?")
    End If
to compare the value with the 1st byte of the Byteconverter result.
 
Upvote 0

Herbert32

Active Member
Licensed User
Longtime User
WoW - GREAT 'THANK YOU'

now i know how to convert a string which contains a hex-value to Byte

you can't imagine how long i took for this simple task

1000x'thank you' <3


best regards
Herbert
 
Upvote 0
Top