datepicker error in appdesigner

5 Ansichten (letzte 30 Tage)
frankenberry
frankenberry am 25 Apr. 2020
Beantwortet: frankenberry am 28 Apr. 2020
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.

Akzeptierte Antwort

frankenberry
frankenberry am 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

Weitere Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by