首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

用FindComponent查找Edit控件出错,该怎么处理

2012-02-23 
用FindComponent查找Edit控件出错源程序procedure TFormRounting.RountingJiShu( arr1: array of Byteaco

用FindComponent查找Edit控件出错
源程序
procedure TFormRounting.RountingJiShu( arr1: array of Byte;
  acount: Integer);
var
  i:Integer;
  C:TComponent;
begin
  for i:=1 to acount do
  begin
  C:= FormRounting.FindComponent('edt'+inttostr(i));
  if C<>nil then
  begin
  arr1[i-1]:=StrToIntDef(TEdit(C).Text,0);
  end;
  end;
end;
运行的时候在 C:= FormRounting.FindComponent('edt'+inttostr(i));
处出错,请高手指教

[解决办法]
C:= FormRounting.FindComponent('edt'+inttostr(i));
改成
C:= FindComponent('edt'+inttostr(i));
[解决办法]
C:= FormRounting.FindComponent('edt'+inttostr(i));
FIndComponent不是窗体类方法,所以报错,直接引用就行了,是TComponent的方法,
改成下 C:= FindComponent('edt'+inttostr(i));面的
[解决办法]
procedure TFormRounting.RountingJiShu( arr1: array of Byte;
acount: Integer);

这里的arr1不是动态数组,是开放数组,这是2个不同的概念

要传动态数组,得先定义一个类型:
type TMyArray=array of byte;
procedure TFormRounting.RountingJiShu( arr1:TMyArray;
acount: Integer);

热点排行