[hurra]
Dzięki KERIM
Myślę że temat zakończony.
Dla wszyskich podaję kod programu z tym przykładem, wraz z przekazaniem zmiennej B do formy 1.
JacekS
[browar] [browar] [browar] [browar] [browar] [browar]
FORMA1 (GŁÓWNA)
unit Unit16;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TForm1 = class(TForm)
Label1: TLabel;
BitBtn1: TBitBtn;
Edit1: TEdit;
Label2: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormClick(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses
unit17;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
a:integer;
begin
try
Form2:=TForm2.Create(Self);
if Form2.ShowModal=mrOk then
a:=1;
finally
Form2.Free;
end;
end;
procedure TForm1.FormClick(Sender: TObject);
begin
edit1.Text:=IntToStr(unit17.B);
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
close;
end;
end.
FORMA 2 (Ta która pierwsza się pokazuje).
unit Unit17;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TForm2 = class(TForm)
Label1: TLabel;
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
B: integer;
implementation
uses
Unit16;
{$R *.dfm}
procedure TForm2.BitBtn1Click(Sender: TObject);
begin
B:= 5;
close;
end;
end.
Oraz plik APLIKACJI
program Project1;
uses
Forms,
Unit16 in 'Unit16.pas' {Form1},
Unit17 in 'Unit17.pas' {Form2};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TForm2, Form2);
Application.Run;
end.
I na tym koniec.
[cya]