Hola moise094 y bienvenido a Club Delphi
Como a todos los que se inician te invitamos a que leas nuestra
guía de estilo.
Una opción puede ser:
Código Delphi
[-]
function ExtraerNum(cad:string): string;
var
i: Integer;
begin
i:=0;
while not (cad[i] in ['0'..'9']) do Inc(i);
repeat
Result:= Result + cad[i];
Inc(i);
until not (cad[i] in ['0'..'9']);
end;
Ejemplo de uso:
Código Delphi
[-]
procedure TForm1.ListBox1Click(Sender: TObject);
begin
with TListBox(Sender) do
Caption:= ExtraerNum(Items[ItemIndex]);
end;
Saludos.