在一个TListBox里面有3016行items,我想从索引1开始,每隔一行赋给一个TMemo,比如TListBox内容为 1 a 2 b 3 c 我想把a,b,c赋给TMemo,最后分别保存到两个TXT文本中,但是为什莫我的代码不对呢: procedure TForm1.Button1Click(Sender: TObject); var i,j: integer; begin j:=0; i:=0; while i<= 3015 do begin Memo1.Lines[j]:= ListBox1.Items[i]; j:=j+1; i:=i+2; end; ListBox1.Items.SaveToFile('e:\n1.txt'); Memo1.Lines.SaveToFile('e:\n2.txt'); end;
----------------------------------------------
ignore,Ctrl+Alt+Del,then begin;is die,but just not die。
procedure TForm1.Button1Click(Sender: TObject); var i: integer; begin for i := 0 to ListBox1.Items.Count - 1 do begin if i mod 2 <> 0 then Memo1.Lines.Add(ListBox1.Items[i]); end; ListBox1.Items.SaveToFile('e:\n1.txt'); Memo1.Lines.SaveToFile('e:\n2.txt'); end;
谢谢,sephil, 不好意思。。。。。。。后来又试了试,我弄了两个TListBox,倒是可以运行的,为什莫我的代码中使用TMemo倒是不行??
----------------------------------------------
ignore,Ctrl+Alt+Del,then begin;is die,but just not die。
请问,我用两个TListBox,然后也是ListBox1.Items[j] := ListBox2.Items[i];但是正常的,这是为什莫呢?
----------------------------------------------
ignore,Ctrl+Alt+Del,then begin;is die,but just not die。