2010年4月21日

DELPHI TListBox (TStrings类)删除空行的方法

摘要: 之前做一个程序,用ListBox读入一个文本文件,但文本中有空行,为了删除其中的空行,折腾了好长时间。 先给出一段代码给大家看var i:Integer;begin ListBox1.Items.LoadFromFile('data.txt'); for i:=0 to ListBox1.Count - 1 do begin if Trim(ListBox1.Items.Strings[i])='' Then ListBox1.Items.Delete(i); end;end; 相信不少人会这样写(包括我以前也是),特别是新手,但是这是行不通的,运行时给出 list index out of 阅读全文

posted @ 2010-04-21 22:19 zimmerk 阅读(2311) 评论(1) 推荐(0) 编辑

导航