unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,Math;type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Label3: TLabel;
Label4: TLabel;
Edit2: TEdit;
Button1: TButton;
procedure Button1Click(Sender:Tobject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
procedure TForm1.Button1Click(Sender:TObject);
var
x,y:integer;
f:Real;
begin
x:=StrToInt(edit1.Text);
y:=x div 500;
case y of 0:f:=x*0.5/100;
1:f:=x*1/100;
2,3:f:=x*1.5/100;
else
f:=x*2/100;end;
edit2.Text:=FloatToStr(f);
end.
//报错信息:[Error] Unit1.pas(48): ';' expected but '.' found
[Error] Unit1.pas(53): Declaration expected but end of file found
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
这是怎么回事
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,Math;type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Label3: TLabel;
Label4: TLabel;
Edit2: TEdit;
Button1: TButton;
procedure Button1Click(Sender:Tobject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
procedure TForm1.Button1Click(Sender:TObject);
var
x,y:integer;
f:Real;
begin
x:=StrToInt(edit1.Text);
y:=x div 500;
case y of 0:f:=x*0.5/100;
1:f:=x*1/100;
2,3:f:=x*1.5/100;
else
f:=x*2/100;end;
edit2.Text:=FloatToStr(f);
end.
//报错信息:[Error] Unit1.pas(48): ';' expected but '.' found
[Error] Unit1.pas(53): Declaration expected but end of file found
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
这是怎么回事
procedure TForm1.Button1Click(Sender:TObject);
var
x, y: integer;
f : Real;
begin
x := StrToInt(edit1.Text);
y := x div 500;
case y of
0 : f := x * 0.5 / 100;
1 : f := x * 1 / 100;
2,3: f := x * 1.5 / 100;
else
f:=x*2/100;
end;
edit2.Text := FloatToStr(f);
end; //这里少了个end;