我在写程序的时候,有两个BitBtn按钮,都是执行以下的操作,
if aaa = 1 then
frm1.close
else if aaa = 0 then
frm2.Label1.caption := 'Szk_2006';
我想把以上代码写成一个函数或者过程.应该怎么写.
在对应的Unit.pas中怎么声明这个函数或者过程.
急..............
在线等待.................................................
if aaa = 1 then
frm1.close
else if aaa = 0 then
frm2.Label1.caption := 'Szk_2006';
我想把以上代码写成一个函数或者过程.应该怎么写.
在对应的Unit.pas中怎么声明这个函数或者过程.
急..............
在线等待.................................................
第一步,声明过程
procedure BtnProc;第二步,实现过程
procedure frm1.BtnProc;
begin
if aaa = 1 then
frm1.close
else if aaa = 0 then
frm2.Label1.caption := 'Szk_2006';
end;第三步,双击BitBtn按钮,写上BtnProc就可以了
procedure procName(aaa: aaaType);
begin
if aaa = 1 then
frm1.close
else if aaa = 0 then
frm2.Label1.caption := 'Szk_2006';
end;方法2,定义为类方法
TForm1 = class(TForm)
//...
procedure procName(aaa: aaaType);
end;TForm1.procName(aaa: aaaType);
begin
//....
end;
begin
if aaa = 1 then
frm1.close
else if aaa = 0 then
frm2.Label1.caption := 'Szk_2006';
end;