在 Form1 中 var Form1:TForm1; i:integer; begin; i=1; end; 在 Form2 中 begin if unit1.i>1 then showmessage('ok'); end;
unit1 type TForm1 = class(TForm) ...... public i:integer; end; var Form1: TForm;unit2 type ...... var Form2:TFormimplementation uses unit1; ..... begin showmessage(inttostr(Form1.i)); end;
var Form1:TForm1;
i:integer;
begin;
i=1;
end;
在 Form2 中
begin
if unit1.i>1 then
showmessage('ok');
end;
type
TForm1 = class(TForm)
......
public
i:integer;
end;
var
Form1: TForm;unit2
type
......
var
Form2:TFormimplementation
uses unit1;
.....
begin
showmessage(inttostr(Form1.i));
end;