If textbox input between 0 and 1

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 件のコメント

Shubham Gupta
Shubham Gupta 2019 年 9 月 23 日
Can you please type in command window:
whos value
and share the result with us ?
Ned
Ned 2019 年 9 月 23 日
In the component browser, consider changing the limits property of the NUMERIC edit field to 0,1. That way you can just have your callback call the function without having to check.
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 件)

カテゴリ

ヘルプ センター および File ExchangeDevelop Apps Using App Designer についてさらに検索

タグ

質問済み:

2019 年 9 月 22 日

コメント済み:

2019 年 9 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by