在两个Form之间传值时出现的错误!
工程文件结构如下:
main.exe
|----employee
|   |----employee.pas
|   |----F_employee_info
|----employee_find
   |-----employee_find.pas
   |-----F_employee_find
程序其实很简单:
在F_employee_find中按一下button1,于是F_employee_info中的button2.caption:=’成功’;
我写的程序如下:
procedure TF_Employee_find.Button1Click(Sender: TObject);
begin
    employee.F_employee_info.Button2.Caption:='成功';
end;我已经在employee的implementation中加上uses Employee_Find;
employee_find的implementation中加上uses employee;
请问为何程序还是通不过?报错时说地址错误!请大家指教,谢谢。

解决方案 »

  1.   

    procedure TF_Employee_find.Button1Click(Sender: TObject);
    begin
       //此时F_employee_info对象你创建了吗?
       if not Assigned(F_employee_info) then
        employee.F_employee_info.Create(Application);
        employee.F_employee_info.Button2.Caption:='成功';
    end;
      

  2.   

    procedure TF_Employee_find.Button1Click(Sender: TObject);
    begin
       //此时F_employee_info对象你创建了吗?
       if not Assigned(F_employee_info) then
        employee:=TF_employee_info.Create(Application);
        employee.F_employee_info.Button2.Caption:='成功';
    end;
      

  3.   

    if Assigned(F_employee_info) then
         employee.F_employee_info.Button2.Caption:='成功'
    else
      showmessage('没有创建F_employee_info');
    end;
      

  4.   

    begin
      try
        Form2 := TForm2.Create(self);
        Form2.Button1.Caption := '成功';
        Form2.ShowModal;
      finally
        Form2.Free;
      end;
    end;
      

  5.   

    两个窗体互相引用时,不能都写在IMPLEMENTION下边。要把一个写到USES中去。你改这块试试。
    还有我建议你在两个窗体中传递一个标志变量,然后根据标志变量来判断。
    还有你在USES中写的是单元名,所以无法引用FORM中的对象,你试试把USES改成FORM。试试。这是我的观点,不知道对不对。