F FreeWolF Active Member Licensed User Longtime User Apr 22, 2014 #1 Hello, how can I put a converted string in a Astream byte array? Code: Copy Dim dati() As Byte dati = Array As Byte(0x01, 0x10, 0x01, 0x0A, 0x00, 0x01, 0x02, 0x01, 0xFF, 0xF7, 0xEA) AStreams.Write(dati) This example works fine. But I want something like this: Code: Copy Dim dati() As Byte Dim testo as string testo = "0x01, 0x10, 0x01, 0x0A, 0x00, 0x01, 0x02, 0x01, 0xFF, 0xF7, 0xEA" dati = Array As Byte(testo) AStreams.Write(dati) How can I do it? I have tried with the second example I have wrote, but I receive: "An Error has occured in sub: java.lang. NumberFormatException: Invalid double: " " Continue? Thanks in advance!!!
Hello, how can I put a converted string in a Astream byte array? Code: Copy Dim dati() As Byte dati = Array As Byte(0x01, 0x10, 0x01, 0x0A, 0x00, 0x01, 0x02, 0x01, 0xFF, 0xF7, 0xEA) AStreams.Write(dati) This example works fine. But I want something like this: Code: Copy Dim dati() As Byte Dim testo as string testo = "0x01, 0x10, 0x01, 0x0A, 0x00, 0x01, 0x02, 0x01, 0xFF, 0xF7, 0xEA" dati = Array As Byte(testo) AStreams.Write(dati) How can I do it? I have tried with the second example I have wrote, but I receive: "An Error has occured in sub: java.lang. NumberFormatException: Invalid double: " " Continue? Thanks in advance!!!
Erel B4X founder Staff member Licensed User Longtime User Apr 22, 2014 #2 1. You will need to split the string with Regex.Split. 2. Trim each of the strings and remove the first two characters. 3. Call Bit.ParseInt to parse the hex number. Upvote 0
1. You will need to split the string with Regex.Split. 2. Trim each of the strings and remove the first two characters. 3. Call Bit.ParseInt to parse the hex number.