Cita:
Empezado por moise094
El caso es el siguiente, voy a abrir un documento .txt en un listbox y este tiene:
JUAN 45
JOSE 56
y quiero que al abrir el archivo, me aparezca en un edit cualquiera el numero 45
es decir el listbox va siempre a tener varios items...
|
Lo mio sería parecido al de ecfisa:
Código Delphi
[-]
function ExtraerNum(Item : String) : String;
var
PosIni : Integer;
Valor : String;
begin
PosIni := Pos(' ', item);
Valor := Copy(item, PosIni+1, Length(item)-PosIni);
Result := Valor;
end;
ListBox1.Items.LoadFromFile('c:\xxx\file.txt');
Edit1.Text := ExtraerNumero(ListBox1.Items[0]);
procedure TForm1.ListBox1Click(Sender: TObject);
begin
Edit1.Text := ExtraerNumero(ListBox1.Items[ListBox1.ItemIndex]);
end;
Saluditos