MATLAB: GUI

guiif statement

How do you transfer information in a GUI? For example, If the user types in (-4) in a text box i want to use a text/edit box to say 'Please enter a positive number.' I don't know how to transfer the information from one function to another. PLEASE HELP!

Best Answer

The GUIs built by GUIDE use the handles structure to share the handles for all the GUI objects, for example:
handles.edit1 %this is the handle for one edit box, edit1 is the box name
get(handles.edit1,'String') %gives you what's inside the edit box 1
%This will put your message on one text box
set(handles.text1,'String','Please enter a positive number.')
For your example you can edit the edit box callback and add a detection, for example:
if str2double(get(handles.edit1,'String'))<0
%Warn the user about the negative input
set(handles.edit1,'String','0') %put zero (default value) on the edit box
end