Hello Kronecker,
There are no Hex numbers. Only Hex Strings. Do you want to send two
bytes which' values are A2 and FF (=162 and 255)? If yes, use the other
overloaded method, like
Dim b As Byte() = {&HA2, &HFF}
serial1.write(b, 0, 2)
In addition to what Armin wrote and my previous posting for the
conversion of a number to hex string and binary string:
Hex as well as Octal are just representations in a different format.
For example the decimal number 25:
In binary it is 00011001,
in octal it is 31 (00 011 001),
in hex it is 19 (0001 1001).
Note that the binary value has never changed, but only the way to
represent it.
So, these variables will always contain the same value:
Dim OctalValue As Byte = &O31
Dim DecimalValue As Byte = 25
Dim HexValue As Byte = &H19
If OctalValue = DecimalValue And OctalValue = HexValue Then
Debug.Print("Values are identical.")
Else
Debug.Print("Values are different.")
End If
So regarding your question, you should consider if you want to send a
string (Dim HexString As String = Hex(25)) or if it is that you want to
send a numeric value (Dim HexValue As Byte = &H19) over the serial port.
Best regards,
Martin