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

11 ビュー (過去 30 日間)
Chun Yin Marcus Ng
Chun Yin Marcus Ng 2019 年 3 月 15 日
回答済み: Jenni French 2019 年 8 月 6 日
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 Center および File ExchangeDevelop 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