菜鸟求助:这个问题我实在搞不定了,望高手指教 ( 积分: 100 )

  • 主题发起人 主题发起人 superstar162
  • 开始时间 开始时间
S

superstar162

Unregistered / Unconfirmed
GUEST, unregistred user!
这是我编的一个到计时的问题,可运行时老提示这个错误:[Error] Unit1.pas(69): Statement expected but 'PROCEDURE' found
我实在不知道是什么问题,望指教!太穷了,没分,只能送100分了
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Timer1: TTimer;
procedure Edit1KeyPress(Sender: TObject;
var Key: Char);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Edit1Exit(Sender: TObject);
procedure Edit2Exit(Sender: TObject);
procedure Edit2KeyPress(Sender: TObject;
var Key: Char);
procedure Timer1Timer(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
daotime:integer;
//用于到计时间保存
daonowtime:integer;
//保存到计时设定时间 分数
daonowmiao:integer;
//保存到计时设定时间 秒数
implementation
{$R *.dfm}
procedure TForm1.Edit1KeyPress(Sender: TObject;
var Key: Char);
begin
if not (key in['0'..'9',#8]) then
begin
application.MessageBox('请输入数字!','提示');
key:=#0;
end;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
begin
if (edit1.Text<>'')and(edit2.Text<>'') then
begin
timer1.Enabled:=true;
edit3.Color:=clPurple;
end
else
begin
application.MessageBox('请输入运行时间!','提示');
edit1.SetFocus;
end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
timer1.Enabled:=false;
edit3.Color:=clwindow;
edit1.Text:='10';
edit2.Text:='10';
edit3.Text:='10';
daotime:=9;
end;

procedure TForm1.Edit1Exit(Sender: TObject);
begin
if StrToInt(edit1.Text)>59 then
begin
application.MessageBox('超出时间范围0~59!','提示');
edit1.Text:='10';
edit1.SetFocus;
edit1.SelectAll;
end;
end;

procedure TForm1.Edit2Exit(Sender: TObject);
begin
if StrToInt(edit2.Text)>59 then
begin
application.MessageBox('超出时间范围0~59!','提示');
edit2.Text:='10';
edit2.SetFocus;
edit2.SelectAll;
end;
end;

procedure TForm1.Edit2KeyPress(Sender: TObject;
var Key: Char);
begin
if not (key in['0'..'9',#8]) then
begin
application.MessageBox('请输入数字!','提示');
key:=#0;
end;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
daonowtime:=StrToInt(edit1.Text);
//取得设定分数
daonowmiao:=StrToInt(edit2.Text);
//取得设定秒数
if (daotime>0)and(StrToInt(edit2.Text)<>0) then
//开始到计时,秒数递减
begin

daotime:=daotime-1;
edit3.Text:=IntToStr(daotime);
end
else
begin
if daonowmiao>0 then
begin
daonowmiao:=daonowmiao-1;
edit3.Text:=IntToStr(daotime);
daotime:=9;
edit2.Text:=IntToStr(daonowmiao);
end
else
begin
if daonowtime>0 then
begin
daonowmiao:=59;
edit2.Text:=IntToStr(daonowmiao);
daonowtime:=daonowtime-1;
edit1.Text:=IntToStr(daonowtime);
daotime:=9;
end
else
begin
timer1.Enabled:=false;
{ if music.Checked=true then
begin
MediaPlayer1.Open;
MediaPlayer1.Play;
end;
if (application.MessageBox('到计时结束!','提示',MB_OK)=1)and(music.Checked=true) then
begin
MediaPlayer1.Stop;
MediaPlayer1.Close;
end;
}
edit3.Text:='10';
daotime:=9;
edit3.Color:=clwindow;
end;
end;
end;
end;

procedure TForm1.FormActivate(Sender: TObject);
begin

daotime:=9;
//设定跑秒时间
end;



procedure TForm1.FormCreate(Sender: TObject);
begin
form1.Show;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
timer1.Enabled:=false;

end;

end.
 
这是我编的一个到计时的问题,可运行时老提示这个错误:[Error] Unit1.pas(69): Statement expected but 'PROCEDURE' found
我实在不知道是什么问题,望指教!太穷了,没分,只能送100分了
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Timer1: TTimer;
procedure Edit1KeyPress(Sender: TObject;
var Key: Char);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Edit1Exit(Sender: TObject);
procedure Edit2Exit(Sender: TObject);
procedure Edit2KeyPress(Sender: TObject;
var Key: Char);
procedure Timer1Timer(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
daotime:integer;
//用于到计时间保存
daonowtime:integer;
//保存到计时设定时间 分数
daonowmiao:integer;
//保存到计时设定时间 秒数
implementation
{$R *.dfm}
procedure TForm1.Edit1KeyPress(Sender: TObject;
var Key: Char);
begin
if not (key in['0'..'9',#8]) then
begin
application.MessageBox('请输入数字!','提示');
key:=#0;
end;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
begin
if (edit1.Text<>'')and(edit2.Text<>'') then
begin
timer1.Enabled:=true;
edit3.Color:=clPurple;
end
else
begin
application.MessageBox('请输入运行时间!','提示');
edit1.SetFocus;
end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
timer1.Enabled:=false;
edit3.Color:=clwindow;
edit1.Text:='10';
edit2.Text:='10';
edit3.Text:='10';
daotime:=9;
end;

procedure TForm1.Edit1Exit(Sender: TObject);
begin
if StrToInt(edit1.Text)>59 then
begin
application.MessageBox('超出时间范围0~59!','提示');
edit1.Text:='10';
edit1.SetFocus;
edit1.SelectAll;
end;
end;

procedure TForm1.Edit2Exit(Sender: TObject);
begin
if StrToInt(edit2.Text)>59 then
begin
application.MessageBox('超出时间范围0~59!','提示');
edit2.Text:='10';
edit2.SetFocus;
edit2.SelectAll;
end;
end;

procedure TForm1.Edit2KeyPress(Sender: TObject;
var Key: Char);
begin
if not (key in['0'..'9',#8]) then
begin
application.MessageBox('请输入数字!','提示');
key:=#0;
end;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
daonowtime:=StrToInt(edit1.Text);
//取得设定分数
daonowmiao:=StrToInt(edit2.Text);
//取得设定秒数
if (daotime>0)and(StrToInt(edit2.Text)<>0) then
//开始到计时,秒数递减
begin

daotime:=daotime-1;
edit3.Text:=IntToStr(daotime);
end
else
begin
if daonowmiao>0 then
begin
daonowmiao:=daonowmiao-1;
edit3.Text:=IntToStr(daotime);
daotime:=9;
edit2.Text:=IntToStr(daonowmiao);
end
else
begin
if daonowtime>0 then
begin
daonowmiao:=59;
edit2.Text:=IntToStr(daonowmiao);
daonowtime:=daonowtime-1;
edit1.Text:=IntToStr(daonowtime);
daotime:=9;
end
else
begin
timer1.Enabled:=false;
{ if music.Checked=true then
begin
MediaPlayer1.Open;
MediaPlayer1.Play;
end;
if (application.MessageBox('到计时结束!','提示',MB_OK)=1)and(music.Checked=true) then
begin
MediaPlayer1.Stop;
MediaPlayer1.Close;
end;
}
edit3.Text:='10';
daotime:=9;
edit3.Color:=clwindow;
end;
end;
end;
end;

procedure TForm1.FormActivate(Sender: TObject);
begin

daotime:=9;
//设定跑秒时间
end;



procedure TForm1.FormCreate(Sender: TObject);
begin
form1.Show;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
timer1.Enabled:=false;

end;

end.
 
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Timer1: TTimer;
{ Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Timer1: TTimer;
}
procedure Edit1KeyPress(Sender: TObject;
var Key: Char);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Edit1Exit(Sender: TObject);
procedure Edit2Exit(Sender: TObject);
procedure Edit2KeyPress(Sender: TObject;
var Key: Char);
procedure Timer1Timer(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
daotime:integer;
//用于到计时间保存
daonowtime:integer;
//保存到计时设定时间 分数
daonowmiao:integer;
//保存到计时设定时间 秒数
implementation
{$R *.dfm}
procedure TForm1.Edit1KeyPress(Sender: TObject;
var Key: Char);
begin
if not (key in['0'..'9',#8]) then
begin
application.MessageBox('请输入数字!','提示');
key:=#0;
end;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin

if (edit1.Text<>'')and(edit2.Text<>'') then
begin
timer1.Enabled:=true;
edit3.Color:=clPurple;
end
else
begin
application.MessageBox('请输入运行时间!','提示');
edit1.SetFocus;
end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
timer1.Enabled:=false;
edit3.Color:=clwindow;
edit1.Text:='10';
edit2.Text:='10';
edit3.Text:='10';
daotime:=9;
end;

procedure TForm1.Edit1Exit(Sender: TObject);
begin
if StrToInt(edit1.Text)>59 then
begin
application.MessageBox('超出时间范围0~59!','提示');
edit1.Text:='10';
edit1.SetFocus;
edit1.SelectAll;
end;
end;

procedure TForm1.Edit2Exit(Sender: TObject);
begin
if StrToInt(edit2.Text)>59 then
begin
application.MessageBox('超出时间范围0~59!','提示');
edit2.Text:='10';
edit2.SetFocus;
edit2.SelectAll;
end;
end;

procedure TForm1.Edit2KeyPress(Sender: TObject;
var Key: Char);
begin
if not (key in['0'..'9',#8]) then
begin
application.MessageBox('请输入数字!','提示');
key:=#0;
end;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
daonowtime:=StrToInt(edit1.Text);
//取得设定分数
daonowmiao:=StrToInt(edit2.Text);
//取得设定秒数
if (daotime>0)and(StrToInt(edit2.Text)<>0) then
//开始到计时,秒数递减
begin

daotime:=daotime-1;
edit3.Text:=IntToStr(daotime);
end
else
begin
if daonowmiao>0 then
begin
daonowmiao:=daonowmiao-1;
edit3.Text:=IntToStr(daotime);
daotime:=9;
edit2.Text:=IntToStr(daonowmiao);
end
else
begin
if daonowtime>0 then
begin
daonowmiao:=59;
edit2.Text:=IntToStr(daonowmiao);
daonowtime:=daonowtime-1;
edit1.Text:=IntToStr(daonowtime);
daotime:=9;
end
else
begin
timer1.Enabled:=false;
{ if music.Checked=true then
begin
MediaPlayer1.Open;
MediaPlayer1.Play;
end;
if (application.MessageBox('到计时结束!','提示',MB_OK)=1)and(music.Checked=true) then
begin
MediaPlayer1.Stop;
MediaPlayer1.Close;
end;
}
edit3.Text:='10';
daotime:=9;
edit3.Color:=clwindow;
end;
end;
end;
end;

procedure TForm1.FormActivate(Sender: TObject);
begin

daotime:=9;
//设定跑秒时间
end;



procedure TForm1.FormCreate(Sender: TObject);
begin
form1.Show;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
timer1.Enabled:=false;

end;

end.

多了个begin
 
daotime:integer;
//用于到计时间保存
daonowtime:integer;
//保存到计时设定时间 分数
daonowmiao:integer;
//保存到计时设定时间 秒数
每行前要加上完整的声明试试
 
我也刚发现并解决了这个问题,不过还是多谢这位仁兄,100分我不吝啬吧,哈哈
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部