Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Abfrage ob Component existiert (https://www.delphipraxis.net/148362-abfrage-ob-component-existiert.html)

SimonRap 28. Feb 2010 13:32


Abfrage ob Component existiert
 
Hi Leute,
gibt es ne Möglichkeit zu prüfen, ob nen Object existiert?
z.B:
Delphi-Quellcode:
...
VAR I:INTEGER; a:TObject;
begin
  for i:=1 to 9 do
  begin
    a:=FindComponent('label'+inttostr(i));
    if componentexists(a) then... //so was z.b.
  end;
end;
...
Gibs so was?

MfG simon

IceBube 28. Feb 2010 13:51

Re: Abfrage ob Component existiert
 
Hi!

Delphi-Quellcode:
VAR I:INTEGER; a:TObject;
begin
  for i:=1 to 9 do
  begin
    a:=FindComponent('label'+inttostr(i));
    if (a) <> nil then... //so was z.b.
  end;
end;
So müssts funktionieren (Nicht getestet)...

lg

DeddyH 28. Feb 2010 15:15

Re: Abfrage ob Component existiert
 
Oder
Delphi-Quellcode:
if Assigned(a)

SimonRap 28. Feb 2010 16:28

Re: Abfrage ob Component existiert
 
thx^^


Alle Zeitangaben in WEZ +1. Es ist jetzt 08:10 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz