0
With the code below I’m trying to find a text in a Tedit,
procedure TForm2.CheckBox3Click(Sender: TObject);
var i: integer;
begin
existeCampo := false;
begin
for i := 1 to form1.variavel do
begin
if TEdit(form1.FindComponent('edt_variavel'+IntToStr(i))).Text = 'dose_adicional' then
begin
existeCampo := true;
break;
checkbox3.Checked := true;
end;
end;
if existeCampo = false then
begin
Showmessage('Para utilizar essa opção, adicione uma variavel com o nome de "dose_adicional");
Checkbox3.Checked :=false;
end;
end;
end;
I’ve done several tests, and he can’t find the text, even though I typed it correctly on Edit, why does this happen?
There is a component
edt_variavel<i>? He is aTEditor some other component?form1.variavel? What is the usefulness of thatx:=0;in the middle of nowhere?– DH.
yes it exists, it is a Tedit, Form1.variable for being from 1 to 15. x = 0 has been removed.
– Guilherme Lima
it’s just a kick, so I won’t put it as an answer, but try to put
as TEditon the return ofFindComponentI think you’re having trouble because it’s transforming the return ofFindComponentwhich is aTComponentin aTEdit, and then in the case he has thename, but you won’t get thetext– DH.
but I do the same thing to get the text and play inside an array, why wouldn’t it work?
– Guilherme Lima