Re: Problems with varibles
I've never seen the Xor operator before, however after looking at the documentation it looks as though it is a boolean value. So I think that the first thing you should do is turn option strict and option explicit on and that would work out a few conversion errors for you.
Re: Problems with varibles
i'm not sure i understand you solution because
this works as it should ---> MsgBox(&H33 Xor &H34) will show the correct answer = "7"
i just need a way to tell the program that the values in EAX and ECX should be treatet as hexvalue so
Msgbox(eax xor ecx) also gives "7" :)
Re: Problems with varibles
Just declare some constants.
C#
Code:
const Int64 EAX = 0x034;
const Int64 ECX = 0x033;
MessageBox.Show((EAX ^ ECX).ToString());
VB.net
Code:
Const EXC As Int64 = &H34
Const ECX As Int64 = &H33
MessageBox.Show((EAX XOr ECX).ToString())
Both these examples will result in 7 as you're requiring.
Re: Problems with varibles
wel i can't do that here are the whole code:
teller = 6
For k = 2 To teller
Delecx = Asc(Mid(Serial_after_check, EDX, 1))
ECX = Delecx.ToString("X2")
EBX = (EBX Xor ECX) <------here is the problem as you can see i can't declare it
EDX = EDX + 1
EAX = EAX - 1
Next k
in the first run of the loop EBX is 33 and ECX is 34 it should be 7 and stored in EBX but, i gives 3 :(
Re: Problems with varibles
Do you understand the difference between a number and a string? Do you understand the difference between decimal and hexadecimal, and how they relate to numbers and strings?
You cannot perform an XOR function on a string. XOR is a bitwise operator, and requires a numeric value. In your example, the variable ECX is a string. Show your declarations, and work from there.
Re: Problems with varibles
Quote:
Do you understand the difference between a number and a string?
That's why I suggested to the OP to turn option strict and explicit on. I haven't tested it, but I'm sure that if it was on, it would've thrown an error.
Re: Problems with varibles
Quote:
Originally Posted by
dday9
That's why I suggested to the OP to turn option strict and explicit on. I haven't tested it, but I'm sure that if it was on, it would've thrown an error.
You are absolutely correct, of course. This should be the first order of the day :)
Re: Problems with varibles
Personally I think knowledge of the difference between a HEX (base 16) value and a DECIMAL (base 10) value needs to be understood... the OP is using 33 when he needs to use &H33 ... they are NOT the same values... Not even close.
&H33 xor &H34 does not produce the same value as 33 xor 34 ... so... if you're extracting HEX values from a string they need to be treated as their HEX values and not as their DECIMAL values... OR... you need to take the hex values and translate them to their decimal values, then xor the two decimal values.
-tg