Sign in to follow this  
Followers 0
PartyPooper

Why won't this work?

3 posts in this topic

This has to be something I'm doing wrong, but for the life of me I can't see what. Are the operators I'm using to equate the Option 1, Option 2 and Option 3 values incorrect? The Help File has <> Test if two values are not equal. so I assume they are correct. B) Any help would be appreciated

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)

$MainGUI = GUICreate("MyGUI", 200, 100, -1, - 1)

GUISetIcon(@SystemDir & "\pifmgr.dll", 27)

GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit")

$ComboBox = GUICtrlCreateCombo("",10, 25, 100, 30)

GUICtrlSetData($ComboBox,"Option 1|Option 2|Option 3","Option 1")

GUICtrlSetOnEvent(-1,"OnComboChoice")

GUISetState(@SW_SHOW)

; GUI Message Loop

While 1

Sleep(200)

WEnd

Func OnComboChoice()

$Choice = GUICtrlRead($ComboBox)

If $Choice <> "Option 1" OR $Choice <> "Option 2" OR $Choice <> "Option 3" Then

MsgBox(262160,"ERROR", $Choice & " IS NOT equal to any test values")

Else

MsgBox(262160,"ERROR", $Choice & " IS equal to a test value")

EndIF

EndFunc

Func OnExit()

Exit

EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try replacing <> with == that way, if they are "Not" equal, it would do your "Else" statement, and if they are equal, they would do the immediate "if" statement.

The way you have it now, if it ever is "Not" equal, it would do your "Else" statement... <> is Less than or Greater than.

Edit:

As an example if you didn't want to change the entire code, you could do:

If Not $Choice <> "Option 1" OR Not $Choice <> "Option 2" OR Not $Choice <> "Option 3" Then

Edit 2:

Gawd!!, I make things so complicated... you could just switch it out like Larry said below!!

Edited by ronsrules

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Now I just feel stupid. Why didn't I pick that up.

Thanks Larry (and Ron for a good try B))

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