I haven't looked at your code closely, but one suggestion (a good one in general) is to work downwards when deleting things - I suspect this could be your problem.
e.g. for tval := Pred(memo1.Lines.Count) downto 0 do HTH, Conor P.S. Not really being anal, but having come back from holiday after two weeks, and wading through emails, is there any chance you could use more descriptive subjects in your emails <grin>? ;-) -----Original Message----- From: Alistair George [mailto:bigal@;xtra.co.nz] Sent: Tuesday, 29 October 2002 1:51 p.m. To: Multiple recipients of list delphi Subject: [DUG]: Headache material Hi all. I am having a problem with tmemo in that if I delete one item in the loop below the memo is stuffed afterwards. But in the second example memo is OK. Any tips?? Logically, memo count is adjusted after one item deleted but tval is inc'd for next. Tval needs to be dec'd prior to next count (I think) but you cant do that! for tval := 0 to memo1.Lines.Count - 1 do begin with memo1.Lines do begin if (directoryexists(strings[tval])) then //its DEFINITELY a directory if not dirhasfile(strings[tval]) then delete(tval) else strings[tval] := IncludeTrailingBackSlash(strings[tval]) + '*.*'; end; end; This works: counter:integer; for tval := 0 to memo1.Lines.Count - 1 do begin with memo1.Lines do begin if (directoryexists(strings[tval])) then //its DEFINITELY a directory if not dirhasfile(strings[tval]) then counter:=tval else strings[tval] := IncludeTrailingBackSlash(strings[tval]) + '*.*'; end; end; memo1.lines.delete(counter); //FINE FOR ONE INSTANCE ONLY! --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi" Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/ --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi" Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/