Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incompatible types 'String' and 'TEdit'

Tags:

delphi

this seems like a really simple one, but i'm new to delphi and google has not turned up anything...

i have an Edit field on my form and i have created a component which has a function of the form:

type
    TComms = class(TComponent)
  published
    function BuildPacket(const APacketData: string): string;

now i pass the output of the edit form to the function like so:

procedure TForm1.xxxxx(Sender: TObject)
var
  NewPacket: string;
begin
  NewPacket := Comms.BuildPacket(EditVal);
end;

and i get the error

Incompatible types 'String' and 'TEdit'

should i convert the Edit value to a string? or should my component do the conversion? i don't want to make the input a property of the component or anything - just an argument to the BuildPacket function.

like image 551
mulllhausen Avatar asked Apr 20 '26 23:04

mulllhausen


1 Answers

Yeah, you're passing the edit box itself, and not the value of it. Try:

NewPacket := Comms.BuildPacket(EditVal.text);
like image 77
dKen Avatar answered Apr 22 '26 17:04

dKen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!