请大家帮忙看看这个程序的错误原因?
这是我自己刚开始学习程序设计写的,照书抄都有错误,真不明白是怎么回事?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
EdtDeg: TEdit;
BtnDegToRad: TButton;
BtnRadToDeg: TButton;
EdtRad: TEdit;
procedure BtnDegToRadClick(Sender: TObject);
procedure BtnRadToDegClick(Sender: TObject);
function DegToRad(Deg:Double):Double;
function RadToDeg(Rad:Double):Double;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.BtnDegToRadClick(Sender: TObject);
var
Deg:Double;
Rad:Double;
begin
Deg:=StrToFloat(EdtDeg.Text);
Rad:=DegToRad(Deg);
EdtRad.Text:=FloatToStrF(Rad,ffFixed,7,3);
end;
procedure TForm1.BtnRadToDegClick(Sender: TObject);
var
Deg:Double;
Rad:Double;
begin
Rad:=StrToFloat(EdtRad.text);
Deg:=RadToDeg(Rad); //弧度转换为度
EdtDeg.Text:=FloatToStrF(Deg,ffFixed,7,3);
end;
function TForm.RadToDeg(Deg:Double):Double; //度转换为弧
begin
Result:=Deg/Pi*180;
end;
function TForm.DegToRad(Rad:Double):Double; //度转换为弧
begin
Result:=Rad/180*Pi;
end;
end.