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!

 Risposta accettata

Paulo Silva
Paulo Silva il 23 Apr 2011

2 voti

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

Più risposte (0)

Categorie

Scopri di più su Just for fun in Centro assistenza e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by