问一个组件循环的有关问题,请问了
问一个组件循环的问题,请教了Delphi(Pascal) code for i:0 to 27 dobeginfor j:0 to self.ComponentCoun
问一个组件循环的问题,请教了
Delphi(Pascal) code for i:=0 to 27 do begin for j:=0 to self.ComponentCount -1 do begin if (i+1)=Components[j].Tag then begin ShowMessage(IntToStr(i)); if (Components[j] is TRzEdit) then begin (Components[j] as TRzEdit).Text := '0'; // (Components[j] as TRzEdit).Text :=AdoQuery_Limit.Fields[i].AsString ; end;
源代码如上所述,我判断窗体上组建的tag值是否跟I+1相等,若相等,则读取对应数据集的值,每次我运行的时候,还没执行到showmessage语句,程序就报错了,报list index of bounds(6),这是为什么呢
[解决办法]self.ComponentCount -1
Components[j].Tag
为啥一个带self,而另一个不带尼,看情形,上面不应该带self
[解决办法]if (i+1)=,之外还有其他代码吗,错误就是越界了,调试看看哪里越界了
[解决办法]当使用了WITH DO语句时:
你若要循环FORM下的元件要用SELF
你若要循环WITH DO中控件下的元件时不用加SELF
当在FORM下自执行时加SELF和不加SELF都一样
可能是这几个情况出了问题
[解决办法]学习了,程序本身不完善,对象缺失
[解决办法]for外面是否用了with,加上self试试