Error Handling Question: How to Loop Until User Enters NUMBERS(!) in GUIDE gui edit boxes and then presses an "Update" button
Show older comments
Hello!
I don't think I have seen the answer to this particular situation. I have a GUIDE gui with several edit boxes (Can't use AppDesigner because of other issues with AppDesigner). The user is to enter numbers into the blank edit boxes and the press an "Update" button that checks that numbers are entered, and returns (via handles) the values in each of the boxes.
THIS code doesn't work:
% --- Executes on button press in update_design_button.
function update_design_button_Callback(hObject, ~, handles)
% hObject handle to update_design_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Test for valid entry
try
Num_Decks = handles.deck_design.String;
num_decks = str2num(Num_Decks);
Num_Holes = handles.hole_design.String;
num_holes = str2num(Num_Holes);
Num_Rows = handles.row_design.String;
num_rows = str2num(Num_Rows);
catch
errmsg = warndlg('Please Enter numbers','Number Please');
uiwait(warndlg(errmsg)); %orMessage));
end
handles.num_decks = num_decks;
handles.num_holes = num_holes;
handles.num_rows = num_rows;
guidata(hObject,handles);
There is a "Close" button elsewhere that should be an available exit, but users should basically get a warning (error?) until they put numbers in all the edit boxes and then hit "Update".
Thanks!
Doug Anderson
Accepted Answer
More Answers (0)
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!