H Herbert32 Active Member Licensed User Longtime User Jun 23, 2018 #1 Hi, hopefully someone can explain to me what i missunderstand I tried following code-snippet: Code: Copy 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?
Hi, hopefully someone can explain to me what i missunderstand I tried following code-snippet: Code: Copy 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 Jun 23, 2018 #2 Code: Copy bc.HexToBytes("FF") returns an Bytearray, not just a single Byte. In your case you need to do something like Code: Copy 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
Code: Copy bc.HexToBytes("FF") returns an Bytearray, not just a single Byte. In your case you need to do something like Code: Copy 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.
H Herbert32 Active Member Licensed User Longtime User Jun 23, 2018 #3 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
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