datepicker error in appdesigner

7 次查看(过去 30 天)
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