B
Bari
I'm currently working my way through "MS VB.NET Step by Step", by Michael
Halvorson, and I have a couple of questions.
1) In the book, they're explaining the following line of code, used in an
encryption algorythm:
msgbox(Asc("A") XOR 50) would display 115, and
msgbox(115 XOR 50) would display 65 (the asc value of the letter A)
The Studio's help description for the XOR operator used in this fashion
(bitwise exclusion on two numeric expressions) follows:
This example uses the Xor operator to perform logical exclusion of the
individual bits of two numeric expressions. The bit in the result pattern is
set if only one of the corresponding bits in the operands are set.
Dim A As Integer = 10
Dim B As Integer = 8
Dim C As Integer = 6
Dim myCheck As Integer
myCheck = (A Xor B) ' Returns 2.
myCheck = (A Xor C) ' Returns 12.
myCheck = (B Xor C) ' Returns 14.
Unfortunately, that's the only explanation given. Do you know exactly what
the XOR operator is doing, there? In the first example, above, it looks
like the result is A-B, and the 3rd example looks like B+C, but I find no
relation in the 2nd example. Obviously, my ideas of the 1st & 3rd are
incorrect. Do you know what kind of math the XOR is actually doing?
2) Also, is there a quick & dirty way to test results of stuff like that?
In command/immediate mode, why does:
? chr("A") and msgbox(chr("A")) get the following response:
The expression cannot be evaluated while in design mode.
-and-
messagebox.show(chr("A")) gets:
Command "messagebox.show(chr("A"))" is not valid
How would I test stuff like that, without actually writing the lines into an
application or form, first & then going to immediate mode, or can I?
I appreciate any help you can offer. Thanks in advance
Bari
Halvorson, and I have a couple of questions.
1) In the book, they're explaining the following line of code, used in an
encryption algorythm:
msgbox(Asc("A") XOR 50) would display 115, and
msgbox(115 XOR 50) would display 65 (the asc value of the letter A)
The Studio's help description for the XOR operator used in this fashion
(bitwise exclusion on two numeric expressions) follows:
This example uses the Xor operator to perform logical exclusion of the
individual bits of two numeric expressions. The bit in the result pattern is
set if only one of the corresponding bits in the operands are set.
Dim A As Integer = 10
Dim B As Integer = 8
Dim C As Integer = 6
Dim myCheck As Integer
myCheck = (A Xor B) ' Returns 2.
myCheck = (A Xor C) ' Returns 12.
myCheck = (B Xor C) ' Returns 14.
Unfortunately, that's the only explanation given. Do you know exactly what
the XOR operator is doing, there? In the first example, above, it looks
like the result is A-B, and the 3rd example looks like B+C, but I find no
relation in the 2nd example. Obviously, my ideas of the 1st & 3rd are
incorrect. Do you know what kind of math the XOR is actually doing?
2) Also, is there a quick & dirty way to test results of stuff like that?
In command/immediate mode, why does:
? chr("A") and msgbox(chr("A")) get the following response:
The expression cannot be evaluated while in design mode.
-and-
messagebox.show(chr("A")) gets:
Command "messagebox.show(chr("A"))" is not valid
How would I test stuff like that, without actually writing the lines into an
application or form, first & then going to immediate mode, or can I?
I appreciate any help you can offer. Thanks in advance
Bari