Xor in vb.net

[size=5]Hi, i'm having the next code in order to send some serial commands to a machine:[/size]
[size=3][color=Blue]Private Sub butSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butSend.Click
Dim COMMAND As String
Dim STX As Byte
Dim ETX As Byte
STX = 2
ETX = 3
SerialPort1.Write(Convert.ToChar(STX))
COMMAND = "01RS"
SerialPort1.Write(COMMAND)
SerialPort1.Write(Convert.ToChar(ETX))
[color=Orange]SerialPort1.Write(Convert.ToChar(3))[/color]
SerialPort1.Write(Convert.ToChar(127))

End Sub[/size][/size][/color]
In this code, i need to xor the "STX" byte with the "COMMAND" string
and to replace the "SerialPort1.Write(Convert.ToChar([color=Red]3[/color]))"
with the result of the calculation.
In this code the 3 belongs to the result of the STX byte xor the "01RS". So i want every time to calculate the XOR because COMMAND is changing.
Thank all of you in advance.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories