利用以下方法:
在form1里面编写函数:
function ExecuteForm1(var S : string) : word;
var
    Form1 : TForm1;
begin

    Form1 := TForm1.createform(application);
    result := form1.showmodual;
    try
    if result = mrOK then
    begin
        S := 'OK';
    end;
    finally
    form1.free;
    end;
    
end;

在form1中添加按钮button,在click事件里写代码:
procedure Button1Click(sender:TObject);
begin
    ModalResult := mrOk;
end;

//-----------------------------------------------------------------

在form2里面调用(首先必须uses form1单元),例如在Button1的click事件里
procedure Button1Click(sender:TObject);
var
    S:string;
begin
    if form1.ExecuteForm1(S) = mrOK then
    begin
    showmessage(S);
    end;
end;

相关文章:

  • 2022-12-23
  • 2022-01-13
  • 2022-12-23
  • 2021-12-27
  • 2021-12-17
  • 2022-12-23
  • 2021-07-17
  • 2021-10-20
猜你喜欢
  • 2021-12-30
  • 2022-12-23
  • 2021-10-13
  • 2021-10-06
  • 2021-05-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案