Put values from a memo into an array

1

I have the following component Memo with the texts:

200:80
177:3306

I need to put this text inside an array , for example, if based on the first line, the text 200 (would be array[1] ) and the 80 (would be array[2] ). Remember that I need to use the : (colon) as a delimiter, and then scroll through it and show in a ShowMessage .

I can not do this at all.

    
asked by anonymous 17.06.2015 / 22:54

1 answer

1

You can use the function ExtractStrings

Var
 Numeros: TStringList;
 Numero: string;
begin
 Numeros := TStringList.Create;

 Memo1.Clear;
 Memo1.Lines.Add('200:80');
 Memo1.Lines.Add('177:3306');

 try
   ExtractStrings([':'], [], pchar(Memo1.Text), Numeros);

   for Numero in Numeros do begin
     Showmessage(Numero);
   end;

 finally
   Numeros.Free;
 end;
    
17.06.2015 / 23:18