|
-
Oct 27th, 2000, 06:28 PM
#1
Thread Starter
Addicted Member
How come the first msgbox returns false and the second msgbox returns true?>
Code:
MsgBox 5 = 5 = 5
MsgBox 5 = 5
-
Oct 27th, 2000, 06:37 PM
#2
Addicted Member
I don't know for sure but I think it has to do with the fact that VB doesn't understand your zomparison.
I have been trying a couple of things and it's with all the lines where there more then one "=" symbol. There where there was one, it worked.
It's just a guess, but I could be right?:Confused:
Catch you later,
Jeroen Hoekemeijer
Code:
If 1 = 2 Then MajorError
-
Oct 27th, 2000, 06:38 PM
#3
Addicted Member
I don't know for sure but I think it has to do with the fact that VB doesn't understand your zomparison.
I have been trying a couple of things and it's with all the lines where there more then one "=" symbol. There where there was one, it worked.
It's just a guess, but I could be right?
Catch you later,
Jeroen Hoekemeijer
Code:
If 1 = 2 Then MajorError
-
Oct 27th, 2000, 06:42 PM
#4
maybe it has something to do with this:
5 = 5 is true
so
5 = 5 =5
is like saying:
True = 5
I don't know, maybe.
-
Oct 27th, 2000, 07:24 PM
#5
Frenzied Member
I think it only does simple equations? Like there are only 2 parts to an equation side1 and side2
-
Oct 27th, 2000, 08:01 PM
#6
Fanatic Member
The reason why the second returns true is because
5=5 -----> True
msgbox 5=5 ---------> true
The reason why the first returns false is because it goes from left to right.
First it compare the first two.
5=5 -----> True
Next, it takes the result of that and compare to the rest.
True=5---> False
msgbox 5=5=5 ---------> false
if you have done it like
msgbox 5=5=true ---------> True
msgbox true=5=5 ---------> False
Chemically Formulated As:
Dr. Nitro
-
Oct 27th, 2000, 08:27 PM
#7
-
Oct 27th, 2000, 09:06 PM
#8
Fanatic Member
Wait a sec. Nonzero values are evaluated as True.
True = (True = 5)
According to vb's rules of boolean logic, ((5=5)=5) should return True.
when you convert True to in integer you get -1; false you get 0.
a = 5
If a Then
Beep
End if
The system would beep. VB violates it's on boolean logic rules. No problem, since I would just use the keyword True or False instead of an expression that ALWAYS returns true or false.
$0.02
-
Oct 28th, 2000, 12:42 AM
#9
Lively Member
Wow agent ... you have been "burning up" the internet.
hehe. I know (bad joke). I hope that your house fire wasn't a great loss.
Cordially,
Flint
-
Oct 28th, 2000, 02:23 AM
#10
OK, heres the solution
VB's "favorite" definition of True (numerically) is -1
so
msgbox -1 = -1 = -1 'returns "True"
because -1 does equal -1
thus
-1 = true
This definition only seems to apply to explicit constants (if you actually hard code the numbers into a comparison) but things like
len("xyz") 'will return an expression that can be used in a boolean situation.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|