Use If statement with the option for a dropdown value as a condition in appdesigner
9 views (last 30 days)
Show older comments
I'm currently trying to create an If else if statement that executes different codes depending on which option the user picks in the dropdown menu. But I'm unable to refer to test the value. So for example in the case where the user picks the first selection from the drop down my code is
if app.SomethingDropDown ==1
i = 1;
elseif app.SomethingDropDown == 2
i =2;
etc.
but for some reason it says i cannot compare it with the values 1 and 2. I've tried as comparing to a string '1' and '2' but it still doesn't work. Can anyone help me pls
0 Comments
Answers (1)
Jenni French
on 6 Aug 2019
Are you accessing the value property?
If you change app.SomethingDropDown == 1 to app.SomethingDropDown.Value == 1 it will evaluate the the value of the drop down is equal to 1 rather than the drop down itself. I suspect the issue is it cannot evaluate the drop down as an object to a number, so this is probably where your code stops working.
0 Comments
See Also
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!