Hello All, i'm having some difficulties understanding the Bit.ParseInt function, i have an array of 9 bytes that i need to send to a bluetooth module, this is the byte array i need to send. I need to have each byte in a spinner like so.
I'm trying to parse the strings into bytearrays like so.
the problem is that when i log the values i get this
B4X:
spinner1.Add("A6")
spinner2.Add("29")
spinner3.Add("7F")
spinner4.Add("BD")
spinner5.Add("CC")
spinner6.Add("12")
spinner7.Add("8E")
spinner8.Add("3D")
spinner9.Add("F2")
I'm trying to parse the strings into bytearrays like so.
B4X:
Sub btnsend_click
Dim bytes() As Byte = Array As Byte(Bit.ParseInt(spinner1.GetItem(0), 16), Bit.ParseInt(spinner2.GetItem(0), 16), Bit.ParseInt(spinner3.GetItem(0), 16), _
Bit.ParseInt(spinner4.GetItem(0), 16), Bit.ParseInt(spinner5.GetItem(0), 16), Bit.ParseInt(spinner6.GetItem(0), 16), Bit.ParseInt(spinner7.GetItem(0), 16))
'Bit.ParseInt(spinner8.GetItem(0), 16, Bit.ParseInt(spinner9.GetItem(0), 16))
For i = 0 To bytes.Length - 1
Log(bytes(i))
Next
End Sub
the problem is that when i log the values i get this
how does the Hex number "A6" gets converted to -90 that does not make sense, Hex "A6" is decimal 166, has anyone else seen this, the only numbers that seem correct are "7F" and "BD" what's going on, can anyone explain what's going on here?-90
41
127
-67
-52
18
-114