GUI
2 views (last 30 days)
Show older comments
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!
0 Comments
Accepted Answer
Paulo Silva
on 23 Apr 2011
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
More Answers (0)
See Also
Categories
Find more on Migrate GUIDE Apps 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!