Filter löschen
Filter löschen

warning for not filled fields in guide

5 Ansichten (letzte 30 Tage)
Radoslav Vandzura
Radoslav Vandzura am 8 Nov. 2015
Kommentiert: Image Analyst am 9 Nov. 2015
Hello All,
I would like to ask you how can I make warning for not filled fields in guide? I want when someone doesnt fill fields, warning will appear at the screen? How should I do it?

Akzeptierte Antwort

Image Analyst
Image Analyst am 8 Nov. 2015
You have to get the fields that you want to check, then use isempty() or length() or something to see if there is anything there
editField = get(handles.edit1, 'String');
if isempty(editField)
message = sprintf('Warning: edit1 is not allowed to be empty!');
uiwait(warndlg(message));
end
  2 Kommentare
Radoslav Vandzura
Radoslav Vandzura am 8 Nov. 2015
Is any way according can I do it together for all fields?
Image Analyst
Image Analyst am 9 Nov. 2015
You're sort of doing it right - once for every field. After all, it's a GUI and there will be just a small, finite number of fields - it's not like there will be thousands of them.
One thing you're doing wrong however is passing the result of get() into str2num(). If the field is empty that will most likely cause an ugly error. It's better to check first and present the user with "friendly" instructions like in my code.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by