Problem of: "if ... else if"

The problem I have with my application is that when I do the test, my application only takes into account the first case (if CheckBox14 ENABLED or CheckBox16 ENABLED), i.e. when I check CheckBox13, I get the result of the CheckBox14 case. Normally my code is good but I can't find the error so that the execution does not stop at the first if (below the When Button1 Click).
Thank you in advance !

LINK OF MY PROJECT BELOW THE PICTURES :

http://ai2.appinventor.mit.edu/#5722281518432256

It's because it always find checkboxes 14 and 16 as enabled and executes the code under the if statement. So basically, in this structure only one set of code will be executed.

If you wish to that both sets of code is executed if both conditions are satisfied, then put this statement in a separate if block.

You mean i must separate the "if" in CheckBox14, 16, 13, 15, 17, 18 ?
i.e: if CheckBox14.Enabled=True then (....)
** else if CheckBox16.Enabled=True then (....)**
** else if CheckBox13.Enabled=True then (....)**
** else if CheckBox15.Enabled=True then (....)**
** else if CheckBox17.Enabled=True then (....)**
** else if CheckBox18.Enabled=True then (....)**

Lets understand what you want to do.
If checkbox 14 OR checkbox 16 are enabled, then you want to perform some tasks....
If checkbox 13 OR checkbox 15 OR checkbox 17 OR checkbox 18 are enabled, then you want to perform some tasks....
I think I got that...

But, my question to you is that at a time should only one task be performed? or both?
Example if checkbox 14 and 17 are enabled, then should both sets of code be executed or only that under checkbox 14?
If it is only under checkbox 14 that should run, then the current code is right, but if you want both sets of code to run, the remove the second condition from ifelse and put it into another if condition.

PS: Checkbox14.enabled or in general any checkbox.enabled returns a boolean value, and you don't need to use the equal to true.
You can simply write - if (checkbox14.enabled or checkbox16.enabled

Oh i found the mistake, i confused between Enabled & Checked.

Thanks anyway !

:ok_man: :man_facepalming:

Be careful henceforth!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.