T
tea_nine
Unregistered / Unconfirmed
GUEST, unregistred user!
代码如下:RUN时提示unsatisfied foward or external declaration :'TForm.Divisor'
请问是哪里出错?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
lblHint: TLabel;
edtNum1: TEdit;
edtNum2: TEdit;
lblRes: TLabel;
btnDivisor: TButton;
btnQuit: TButton;
function Divisor(x,y:integer):integer;
procedure btnQuitClick(Sender: TObject);
procedure btnDivisorClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function Divisor(x,y:integer):integer;
var r:integer;
begin
r:=x mod y;
while r<>0 do
begin
x:=y;
y:=r;
r:=x mod y;
end;
Divisor:=y;
end;
procedure TForm1.btnQuitClick(Sender: TObject);
begin
close
end;
procedure TForm1.btnDivisorClick(Sender: TObject);
var m,n,g:integer;
begin
m:=strtoint(edtNum1.text);
n:=strtoint(edtNum2.text);
g:=divisor(m,n);
lblRes.caption:='最大公约数为:'+inttostr(g);
end;
end.
请问是哪里出错?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
lblHint: TLabel;
edtNum1: TEdit;
edtNum2: TEdit;
lblRes: TLabel;
btnDivisor: TButton;
btnQuit: TButton;
function Divisor(x,y:integer):integer;
procedure btnQuitClick(Sender: TObject);
procedure btnDivisorClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function Divisor(x,y:integer):integer;
var r:integer;
begin
r:=x mod y;
while r<>0 do
begin
x:=y;
y:=r;
r:=x mod y;
end;
Divisor:=y;
end;
procedure TForm1.btnQuitClick(Sender: TObject);
begin
close
end;
procedure TForm1.btnDivisorClick(Sender: TObject);
var m,n,g:integer;
begin
m:=strtoint(edtNum1.text);
n:=strtoint(edtNum2.text);
g:=divisor(m,n);
lblRes.caption:='最大公约数为:'+inttostr(g);
end;
end.