Use If statement with the option for a dropdown value as a condition in appdesigner
11 ビュー (過去 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
0 件のコメント
回答 (1 件)
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.
0 件のコメント
参考
カテゴリ
Help Center および File 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!