Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Xor in vb.net

xautomxautom Posts: 1Member
[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.