How to resolve empty inputdlg box issue?

8 ビュー (過去 30 日間)
John Doe
John Doe 2020 年 7 月 12 日
コメント済み: Star Strider 2023 年 5 月 21 日
Hello everyone!
I have a inputdlg box. I want the inputdlg box to cancel the processing if the user pressed OK without giving any input in the inputdlg box. How can I do that?
I know how to cancel the processing if Cancel or the close button is pressed.
Thanks in advance!

採用された回答

Star Strider
Star Strider 2020 年 7 月 12 日
Try this:
a = inputdlg('Type a number:')
if isempty(a{:})
disp('a is empty') % Information Only To Demonstrate That The Test Works
return
end
fprintf('a = %f\n', str2double(a))
.
  2 件のコメント
Mpho
Mpho 2023 年 5 月 21 日
Hi, thanks for the helpful answer. Could you please explain what the colon does?
Star Strider
Star Strider 2023 年 5 月 21 日
My pleasure!
The documentation on colon, : can explain it better than I can!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by