Sign in to follow this  
Followers 0
Guest EES

Autoit 3 OR switch

5 posts in this topic

$vHealthCheck = ($vHealth / 25)

If $vHealthCheck = 1 OR 2 OR 3 OR 4 Then

MsgBox(0, "Congratz", "It works great")

Else

MsgBox(0, "Failed", "Your number is incorrect")

EndIf

That's what I have so far, but it always comes back as the first message box (The correct one)

I have used numbers like 20 and 5 and 125.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

If $vHealthCheck = 1 OR 2 OR 3 OR 4 Then

$vHealthCheck = ($vHealth / 25)
If $vHealthCheck = 1 OR $vHealthCheck =2 OR $vHealthCheck =3 OR $vHealthCheck =4 Then
MsgBox(0, "Congratz", "It works great")
Else
MsgBox(0, "Failed", "Your number is incorrect")
EndIf

Use of Or sounds like your problem.

if 1 then
MsgBox(0, "Congratz", "It works great")
endif

actually a good spot for line continuation Shameless plug of Unofficial help file

$vHealthCheck = ($vHealth / 25)
If $vHealthCheck = 1 OR _
 $vHealthCheck =2 OR _
 $vHealthCheck =3 OR _
 $vHealthCheck =4 Then
MsgBox(0, "Congratz", "It works great")
Else
MsgBox(0, "Failed", "Your number is incorrect")
EndIf
Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

Alright, thanks, I'll use that for now. But if anyone can determine if OR is allowed, please let me know.

Share this post


Link to post
Share on other sites

Sorry for the double post, but I can't click the edit button without getting logged out. But I found the answer!! The correct usage is

If $vHealthCheck = 1 OR $vHealthCheck = 2 OR $vHealthCheck = 3 OR $vHealthCheck = 4

Share this post


Link to post
Share on other sites

$vHealthCheck = ($vHealth / 25)
If $vHealthCheck = 1 OR _
 $vHealthCheck =2 OR _
 $vHealthCheck =3 OR _
 $vHealthCheck =4 Then
MsgBox(0, "Congratz", "It works great")
Else
MsgBox(0, "Failed", "Your number is incorrect")
EndIf

He gave you the correct answer there, lines contiued with the underscore, is the only difference.


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

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