Edit box - Want an error message when a negative value is entered (Beginner)
Show older comments
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
Answers (1)
Mathew
on 6 Mar 2012
Categories
Find more on MATLAB 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!