How to resolve empty inputdlg box issue?

Illustration
Lillian - 2020-07-13T11:51:34+00:00
Question: How to resolve empty inputdlg box issue?

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.

Expert Answer

Profile picture of Neeta Dsouza Neeta Dsouza answered . 2025-11-20

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))


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!