i want to evaluate this textbox for validation. but i got this error.
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
ARYA NAYAK
il 24 Dic 2016
Commentato: ARYA NAYAK
il 25 Dic 2016
Error
Undefined variable "handles" or class "handles.t1".
Error in DESIGN>b1_Callback (line 292)
x=get(handles.t1,'string');
Error while evaluating UIControl Callback
For this code
f=figure;
t1= uicontrol(f,'Style','edit','String','','Position',[180 580 130 20]);
b1 = uicontrol(f,'Style','pushbutton','String','GENERATE','Position',[100 365 100 40],'Callback',@b1_Callback);
function b1_Callback(source,eventdata)
x=get(handles.t1,'string');
if(isempty(x))
msgbox('enter the text');
else
msgbox('ds');
end
Please solve this error
2 Commenti
Risposta accettata
Walter Roberson
il 24 Dic 2016
handles is not automatically passed by MATLAB. When you create a callback using GUIDE then GUIDE arranges for the callback to be passed but when you create your own callback then you have to pass it yourself if you want it. (You also have to create the handles structure yourself)
3 Commenti
Walter Roberson
il 24 Dic 2016
handles.f=figure;
handles.t1= uicontrol(f,'Style','edit','String','','Position',[180 580 130 20]);
handles.b1 = uicontrol(f,'Style','pushbutton','String','GENERATE','Position',[100 365 100 40],);
set(handles.b1, 'Callback', {@b1_Callback, handles});
function b1_Callback(source, eventdata, handles)
x=get(handles.t1,'string');
if(isempty(x))
msgbox('enter the text');
else
msgbox('ds');
end
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Desktop in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!