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!

 採用された回答

Paulo Silva
Paulo Silva 2011 年 4 月 23 日

2 投票

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

1 件のコメント

Brianne Behr
Brianne Behr 2011 年 4 月 23 日
Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeJust for fun についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by