API 2 ChrB to ChrByte

XOJO 2020r2.1 - Windows 10 Desktop

Following code exixts in my XOJO 2018r4 version and works fine:
s2 = efInputText.text
Var last As Integer = s2.CountFields(" “)
If s2.NthField(” “, 1) = “FF” And s2.NthField(” “, 4) = “43” Then
For i = 1 To last
X = X + ChrB(Val(”&H" + s2.NthField(" ", i).Trim))
Next
Else
MessageBox(“First byte needs to be FF and fourth byte 43”)
End If

S2 is a string “FF 22 04 43 01 02 03”
X is a CString
I am trying to change the ChrB to String.ChrByte but I can’t figure out how ?

Following code didn’t work :
X = X + Val("&H" + s2.NthField(" ", i).Trim).ChrByte
Thanks
Regards

x = x + String.ChrByte(CType("&H" + s2.NthField(" ", i).Trim, String).Val)

Totally not intuitive, so many things you can’t do that just make sense. Horrible isn’t it :frowning:

WOW that works. Great.
To be honest, I never would have found that.
Thank you very much.
On to the next API1 to API2 stumbling block.

Regards