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