写点太多了
function Find(const Name: string): TComponent;
begin
for I := 0 to Self.ComponentCount - 1 do
if SameText(Components[I].Name, Name) then
begin
Result := Components[I];
Exit;
end;
Result := nil;
end;////////////////////
var
L: TLabel;
for I := 0 to 20
begin
L := TLabel(Find(Format('Label%d', [I])));
if L <> nil then
begin
//do do do
end;
end;
function Find(const Name: string): TComponent;
begin
for I := 0 to Self.ComponentCount - 1 do
if SameText(Components[I].Name, Name) then
begin
Result := Components[I];
Exit;
end;
Result := nil;
end;////////////////////
var
L: TLabel;
for I := 0 to 20
begin
L := TLabel(Find(Format('Label%d', [I])));
if L <> nil then
begin
//do do do
end;
end;
var
vLabel: TLabel
I: Integer;
begin
for I := 1 to 20 do begin
vLabel := FindComponent('Label' + IntToStr(I));
if Assigned(vLabel) then begin
//do do do
end;
end;
end;
TObject
TComponent
TControl
TWinControl
....
看看TypInfo这个单元
有很多好东东