Edit box - Want an error message when a negative value is entered (Beginner)
Ältere Kommentare anzeigen
Can anyone explain to me why this is not working for me. There are no error messages - it just doesn't give me any error box.
function edit1_Callback(hObject, eventdata, handles)
function edit1_CreateFcn(hObject, eventdata, handles)
strng=get(gcbo,'string');
if ~isempty(strng)
val=str2num(strng);
if val < 0
errordlg('Value cannot be negative','Error','modal');
set(gcbo,'string','Try again');
end
end
Antworten (1)
Mathew
am 6 Mär. 2012
Kategorien
Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!