필터 지우기
필터 지우기

datepicker error in appdesigner

조회 수: 7 (최근 30일)
frankenberry
frankenberry 2020년 4월 25일
답변: frankenberry 2020년 4월 28일
I'm receiving the following error for my text area calculation of age from a datepicker:
Error setting property 'ageNEQO' of class 'A_QuestionnairesR3'. Value must be of type matlab.ui.control.TextArea or be convertible to matlab.ui.control.TextArea.
The previous code in a datepicker callback function worked and output the age in the TextArea in the previous version of Matlab.
% Value changed function: DatePicker_DoB
function DatePicker_DoBValueChanged(app, event)
% calculate age
app.DatePicker_DoBValueChanged;
age = app.DatePicker_DoB.Value;
DisplayFormat = 'yyyy-mm-dd';
datenow = datestr(now, DisplayFormat);
ageout = datestr(age - datenow, 'yy');
app.TextArea_ageNEQO.ValueChangedFcn = {ageout, string};
if app.TextArea_ageNEQO == ""
uialert(app.UIFigure, {'You need to enter your', 'date of birth to proceed.'}, 'Error', 'Icon', 'Error');
end
Now, the calculation for age is not working and there is no output except the error message above.
I need to use the datepicker on a tab with its own callback function. How do I call the DatePicker function on that tab?
DoB = date of birth
datenow should give me the date from my laptop.
app.TextArea_ageNEQO is a TextArea to write the result of the calculation for ageout.

채택된 답변

frankenberry
frankenberry 2020년 4월 28일
I was able to get most of the datepicker to work now.
age = app.DatePicker_DoB.Value;
DisplayFormat = 'yyyy-mm-dd'; %
datenow = datestr(now, DisplayFormat); %DisplayFormat
ageout = datestr(age - datenow, 'yy');
app.TextArea_ageNEQO.ValueChangedFcn = {ageout, string};
app.TextArea_ageNEQO.Value = [ageout];
if app.TextArea_ageNEQO.Value == ""
uialert(app.UIFigure, {'You need to enter your', 'date of birth to proceed.'}, 'Error', 'Icon', 'Error');
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by