for i:=0 to frmbook.ListBox1.Items.Count-1 do
begin
if frmbook.ListBox1.Items[i]=zh.Text then
frmbook.ListBox1.Items.Delete(i) ;
end;
出现以下异常:
class with message estringlisterror
'list index out of bounds(1)'
如何解决?
begin
if frmbook.ListBox1.Items[i]=zh.Text then
frmbook.ListBox1.Items.Delete(i) ;
end;
出现以下异常:
class with message estringlisterror
'list index out of bounds(1)'
如何解决?
Var k:integer;
k:=frmbook.ListBox1.Items.Count-1;
for jsq:=0 to k do
begin
if frmbook.ListBox1.Items[i]:=zh.Text then
begin
frmbook.ListBox1.Items.Delete(i);
K:=K-1;//将K的值减1,因为列表框的项目数已经少了一项了。
end;
end;
begin
if frmbook.ListBox1.Items[i]=zh.Text then
frmbook.ListBox1.Items.Delete(i) ;
end;
当你删除了一行之后,frmbook.ListBox1.Items.Count[2]就越界了