I am trying to write a procedure in delphi.
This procedure gets the name of TControl
descendent element and then try to change some properties.
But when i try to do it, Delphi gives an error like:
E2033 Types of actual and formal var parameters must be identical
Procedure:
procedure Change_prop(var Control: TControl;height:integer;width:integer);
begin
//......
end;
Usage Example : Change_prop(Label1, 50,200);
What can be the solution of that error..Thanks.
The Actual parameters are the variables that are transferred to the function when it is requested. The Formal Parameters are the values determined by the function that accepts values when the function is declared.
formal parameter — the identifier used in a method to stand for the value that is passed into the method by a caller. actual parameter — the actual value that is passed into the method by a caller. For example, the 200 used when processDeposit is called is an actual parameter.
formal parameter — the identifier used in a method to stand for the value that is passed into the method by a caller. For example, amount is a formal parameter of processDeposit.
You just need to remove the var in the Control parameter and make it a value parameter. Because Delphi objects are actually implemented as reference types, you can call methods on them, change member fields etc. even if you pass them to a procedure as a value or const parameter.
Just remove var - you don't need it to change Control's properties:
procedure Change_prop(Control: TControl;height:integer;width:integer);
begin
......
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With