Clear Filters
Clear Filters

datepicker error in appdesigner

7 views (last 30 days)
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.

Accepted Answer

frankenberry
frankenberry on 28 Apr 2020
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

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!