Sign in to follow this  
Followers 0
xzaz

Little question with OR

4 posts in this topic




This is a demo, hope it helps

For $i = 1 To 8

    If $i = 1 Or $i = 2 Or $i = 7 Then
        MsgBox(0, $i, "$i = 1 OR $i = 2 OR $i = 7", 2)
    ElseIf $i = 3 Then
        MsgBox(0, $i, "$i = 3", 2)
    Else ; not found
        MsgBox(0, $i, "Not Found", 2)
    EndIf

Next

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Should be more like

$i = 3

if $i == 1 Or $i == 2 Or $i == 7 Then
    MsgBox(0,"","Yhe!")
Else
    msgBox(0,"","NO!")
Endif

Break it down:

if $i == 1 OR $i == 2 OR $i == 7 Then

So $i can be any one of 1 or 2 or 7 to fire the "Yhe!" MsgBox

If the statement was made with AND then the condition could never be met.

Due to $i can not be a 1 and 2 and 7 all at the same time.

So the ,"Yhe!" msgbox could never be reached

And would mean all conditions must be met

Or would mean any one of the conditions can be met.

I don't think I explained it very well , but I had a go at it..lol

Cheers

Edit: damn I'm slow .. there was no posts when I started responding .

Edited by smashly

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