各位高手们,你们好!我是一个新手,今天编了一个程序,程序的内容是这样的:unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
SpeedButton7: TSpeedButton;
SpeedButton8: TSpeedButton;
SpeedButton9: TSpeedButton;
SpeedButton10: TSpeedButton;
SpeedButton11: TSpeedButton;
SpeedButton12: TSpeedButton;
SpeedButton13: TSpeedButton;
SpeedButton14: TSpeedButton;
SpeedButton15: TSpeedButton;
SpeedButton16: TSpeedButton;
procedure FormCreate(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton12Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
var
s:word;
x,y:real;
v:boolean;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
s:=0;
x:=0;
y:=0;
v:=false;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
if form1.Tag=1 then
begin
if tag=10 then panel2.Caption:='0.'
else panel2.Caption:=(sender as tspeedbutton).Caption;
form1.Tag:=0;
end
else panel2.Caption:=panel2.Caption+(sender as tspeedbutton).Caption;
end;
procedure TForm1.SpeedButton12Click(Sender: TObject);
begin
form1.Tag:=1;
if v then
begin
x:=strtofloat(panel2.Caption);
v:=not v;
end
else
begin
y:=strtofloat(panel2.Caption);
case s of
0:panel2.Caption:=format('%g',[x+y]);
1:panel2.Caption:=format('%g',[x-y]);
2:panel2.Caption:=format('%g',[x*y]);
3:if y<>0 then
panel2.Caption:=format('%g',[x/y]);
else
begin
showmessage('不能以0为除数!');
panel2.Caption:=format('%g',[x]);
v:=false;
end;
4:begin
y:=0;
v:=false;
end;
end;
x:=strtofloat(panel2.Caption);
end;
s:=(sender as tspeedbutton).Tag;
end;
end.
但在我运行此程序时却出现了这样的出错提示:
[Error]Unit1.pas[90]:Undeclared identifier:'4'
[Fatal Error]Project1.dpr[5]:Could not compile used unit'Unit1.pas'
我找了好久都找不出原因,请各位高手帮帮忙,看下问题出在哪?
小弟在这先谢谢各位高手们!