Converting double to a handle

200 views (last 30 days)
DARLINGTON ETAJE
DARLINGTON ETAJE on 23 Apr 2020
Commented: Adam Danz on 28 Nov 2022
When I run the app designer, I keep getting the error
Error setting property 'EditField' of class 'Name0fGui':
Cannot convert double value 2 to a handle
Here is the code
properties (Access = private)
counter1=0 % Description
counter2=0 % Description
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: Button
function ButtonPushed(app, event)
value1=app.ChestPainCheckBox.Value;
if value1==1
app.counter1=app.counter1+1;
else
app.counter1=app.counter1;
end
value2=app.LuckyDipMaCheckBox.Value;
if value2==1
app.counter2=app.counter2+1;
else
app.counter2=app.counter2;
end
value3=app.AbrosyeCheckBox.Value;
if value3==1
app.counter1=app.counter1+1;
else
app.counter1=app.counter1;
end
value4=app.UnclemidadaCheckBox.Value;
if value4==1
app.counter2=app.counter2+1;
else
app.counter2=app.counter2;
end
app.EditField=app.counter1;
app.EditField2=app.counter2;
end
end
  2 Comments
Adam Danz
Adam Danz on 28 Nov 2022
There are a few lines of your code that looks like this
app.a(i+1)=y(i);
app.a is an object handle but you are trying to assign a value to the handle instead of assigning the value to the object's property. You probably mean app.a.Value(i) = y(i); There is >1 line of code that needs fixed so look carefully.
Also, this looks fishy for the same reason:
app.b(i+1)=app.b(i);

Sign in to comment.

Accepted Answer

Adam Danz
Adam Danz on 23 Apr 2020
Try
app.EditField.Value = app.counter1;
app.EditField2.Value = app.counter2;
% ^^^^^^
If that doesn't fix the problem, please provide the entire error message and point to the line that is causing the error.
  4 Comments
Adam Danz
Adam Danz on 24 Apr 2020
Glad I could help!

Sign in to comment.

More Answers (0)

Categories

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

Tags

Community Treasure Hunt

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

Start Hunting!