菜问题"List index out of bounds(-1)"是什么原因?(10分)

  • 主题发起人 sundayyoung
  • 开始时间
S

sundayyoung

Unregistered / Unconfirmed
GUEST, unregistred user!
菜问题"List index out of bounds(-1)"是什么原因?
 
就是说你的listbox或是别的什么的itemindex小于0了,缢出了。加个判断
 
越界。已经有不少这样的帖子了!!!
自己看看你出错的代码,这种错误应该禁止掉。
 
谢,以后会注意的!
 
多人接受答案了。
 
比如你定义了一个动态数组
var
A: array of Byte;
begin
SetLength(A, 2);
A[2] := 0; // 这句就会出“List index out of bounds”错,因为A数组下标为0~1
end;
 
顶部