Use a secondary TStringList:
procedure TForm2.Button1Click(Sender: TObject);
var
I:Integer;
pages:Integer;
items: TStringList;
begin
pages := ceil(Memo1.Lines.Count/100);
Memo2.Lines.add('Total Pages: ' + IntToStr(pages));
Memo2.Lines.add('Total Items: '+ IntToStr(Memo1.Lines.Count));
items := TStringList.Create;
try
for I := 0 to Memo1.lines.Count - 1 do
begin
items.Add(Memo1.Lines.Strings[i]);
if (items.Count mod 100) = 0 then
begin
// process the current list of items...
Memo2.Lines.AddStrings(items);
items.Clear;
end;
end;
if items.Count > 0 then
begin
// process the remaining items...
Memo2.Lines.AddStrings(items);
end;
finally
items.Free;
end;
end;
Remy Lebeau - TeamB
2010-03-05 01:36:00