Read lines from a Txt file and play in different Edits [closed]

-2

I have the following structure of .Txt :

--------DEF--------
3
25
3
2
46
------PROF1----------
0-20 cm
100%
100%
100%
10%
33%
0%
100%
0%
Outro

I would like that when the user chooses the option of .Txt in comboBox , that is equal to the name of the file he would throw the value of each line in a different edit something like this:

Edit1.text = linha 2
edit2.text = linha 3 
...
    
asked by anonymous 23.03.2016 / 14:10

1 answer

2

try:

procedure TForm1.btnProcessarClick(Sender: TObject);
var
   stlArquivo: TStringList;
begin
   stlArquivo := nil;
   try
      stlArquivo := TStringList.Create;
      stlArquivo.LoadFromFile('seuarquivo.txt');
      edtNome.Text := stlArquivo[1];
      edtSobrenome.Text := stlArquivo[2];
   finally
      if Assigned(stlArquivo) then FreeAndNil(stlArquivo);
   end;
end;
    
23.03.2016 / 15:02