用FindComponent查找Edit控件出错,该怎么处理
用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);
源程序
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);