If textbox input between 0 and 1

조회 수: 3 (최근 30일)
SBakc
SBakc 2019년 9월 22일
댓글: Ankit 2019년 9월 23일
I am trying to check the value a user enters into a textbox in the App Designer interface. The value the user inputs must be between 0 and 1.
value = app.EditField.Value;
if (value >= 0 && value <=1)
% call function
else
msgbox("Value must be a value between 0 and 1.");
end
This is not working correctly. For example, if I enter 0 or 1, it outputs the message. If I input a value between 0 and 1 I get this error:
Operands to the || and && operators must be convertible to logical scalar values.
How can I fix this? Thank you.
  댓글 수: 4
Walter Roberson
Walter Roberson 2019년 9월 23일
I suspect the edit field is outputing text.
Ankit
Ankit 2019년 9월 23일
Just use Edit Field (Numeric) instead of Edit Field (Text) from the Component Library.
You can also confirm Edit field property in App initialization and construction section
app.EditField = uieditfield(app.xxx,'text');
I tried and its working for me.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Code Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by