1、首先在form2中写一个过程来接收外部参数
private
 getss:string;//form2中为全局变量procedure getparam(ss:string);
begin
getss:=ss;
end;2、在form1中写
 
 application.createform(Tform2,form2);
 form2.getparam(aa); aa为form1中的变量
 form2.showmodal;
第二种方案:在form1中定义
var 
aa:string;在form2中uses unit1;
就可以使用form1中的变量
不过这种效果不是很好。建议使用第一种方案!

解决方案 »

  1.   

    在form1的 var
               Form1: TForm1;下声明 cust_id
    在form2的 uses 里加上 unit1,就可以在form2中任何地方用cust_id了
      

  2.   

    1、在主窗体定义全局变量
    2、在子窗体重新定义
    我以cbc给例子吧!
    子窗体的定义:
    private: // User declarations
          String str_temp;//自定义
    public: // User declarations
            __fastcall TForm2(TComponent* Owner);
            __fastcall TForm2(String *pstr_temp,TComponent* Owner);
    };__fastcall TForm1::TForm1(TComponent* Owner)
            : TForm(Owner)
    {
         pstr_temp=str_temp;
    }
    //--子窗本关闭事件
        str_temp="ok"//---主窗体
    __fastcall TForm1::Button1Click(TObject* Sender)
            : TForm(Owner)
    {
          String str1="";     
          TForm2 *Form2=new TForm2(&str1,this);
          Form2->ShowModal();
          Edit1->Text=str1;//主窗体
    }