Propriedade Name de Label

Delphi

16/09/2003

Como capturar o número da Propriedade Name de um TLabel ou um TImage?
Propriedade Name: Label58 (só o 58 por exemplo)
Tentei assim mas não deu!
var
strLabel:string;
begin
strLabel:=TLabel(FindComponent(´Label´+inttostr($d))).name;
end;


Ilaera

Ilaera

Curtidas 0

Respostas

Adriano Santos

Adriano Santos

16/09/2003

procedure TForm1.Button1Click(Sender: TObject);
var
strLabel : String;
I : Integer;
Function SomenteNumero(Texto : String ) : String ;
Var
x,i : Integer ;
xTexto : String ;
Begin
Result := ´´ ;
{Retorna Somente os Numeros de uma String}
For i:=1 to Length(Texto) do
Begin
Try
If not (Texto[i] in [´0´..´9´]) then
Continue ;
x := StrToInt(texto[i]) ;
Result := Result + IntToStr(x);
Except
End;
End;
End;


begin
for I := 0 to Form1.ComponentCount-1 do begin
if Components[I] is TLabel then begin
strLabel := ´Nº do LAbel ´+ TLabel(Components[I]).Name + ´: ´ +
SomenteNumero(TLabel(Components[I]).Name);
ListBox1.Items.Add(strLabel);
end;
end;
end;


GOSTEI 0
POSTAR