Sign in to follow this  
Followers 0
tarre

< > = <> == ? confused

6 posts in this topic

Hellow fellas. im wondering what <> and == means in if-stats

i know what < and >, = means but not <> and == . so could anyone tell me :)?

Share this post


Link to post
Share on other sites



Hellow fellas. im wondering what <> and == means in if-stats

i know what < and >, = means but not <> and == . so could anyone tell me :)?

<> means not equal.

ie: (1 <> 2) true

== is only for strings, and means case sensitive equal.

ie: ('Hello' == 'hello') false

('Hello' == 'Hello') true

Look in the help file under Operators.

Share this post


Link to post
Share on other sites

<> means not equal.

ie: (1 <> 2) true

== is only for strings

Almost. Boolean values also take advantage of "==" as comparing operand as well:

if 0 = False Then 
    MsgBox(0,"one ""="" used","0=False is true")
Else
    MsgBox(0,"one ""="" used","0=False is *NOT* true")
EndIf

if 0 == False Then 
    MsgBox(0,"two ""=="" used","0==False is true")
Else
    MsgBox(0,"two ""=="" used","0==False is *NOT* true")
EndIf

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

Not exactly as you think. You know what's happening there? The == is converting False and 0 into strings. So it's not comparing Boolean(False) to Integer(0), it's comparing String(0) to String(False) (which obviously returns false).

Case in point:

MsgBox(0, 'False = "False"', False = "False")
MsgBox(0, 'False == "False"', False == "False")

Sorry to revive an old thread, but I had to correct this incorrect thinking.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Not exactly as you think. You know what's happening there? The == is converting False and 0 into strings. So it's not comparing Boolean(False) to Integer(0), it's comparing String(0) to String(False) (which obviously returns false).

Case in point:

MsgBox(0, 'False = "False"', False = "False")
MsgBox(0, 'False == "False"', False == "False")

Sorry to revive an old thread, but I had to correct this incorrect thinking.

I see, thanks for clarifying!

I used it so far for

If <expression> Then

statements, when I wanted to be sure, that it's not a "0" (which is resulting in the same action as a boolean "False") but a real, boolean "False".

But due to your esplanation, this doesn't ensure that as well. So I think I'd need to use

if (not <expression>) and (<expression> == "False") then

to ensure, that <expression> is really a boolean "False", right?

The first one checks, that it's not the String "False", the 2nd one, that it's not "0".

Regards, Rudi.

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0