Use If statement with the option for a dropdown value as a condition in appdesigner

9 次查看(过去 30 天)
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

回答(1 个)

Jenni French
Jenni French 2019-8-6
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.

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by