标题:Declaration expected but end of file found??
只看楼主
pskk
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-6-13
 问题点数:0 回复次数:1 
Declaration expected but end of file found??

错误:[Error] Unit7.pas(456): Declaration expected but end of file found
[Fatal Error] Unit1.pas(35): Could not compile used unit 'Unit7.pas'

unit unit7;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Menus, Grids, DBGrids, ComCtrls, DB, ADODB, StdCtrls,
Buttons, DBCtrls, Mask;

type
TForm7 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
MainMenu1: TMainMenu;
N1: TMenuItem;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
ADODataSet1: TADODataSet;
PageControl2: TPageControl;
TabSheet3: TTabSheet;
TabSheet4: TTabSheet;
N2: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
SpeedButton3: TSpeedButton;
DBGrid2: TDBGrid;
StatusBar1: TStatusBar;
StatusBar2: TStatusBar;
DataSource2: TDataSource;
Panel4: TPanel;
GroupBox1: TGroupBox;
Label3: TLabel;
Edit2: TEdit;
Label4: TLabel;
Edit3: TEdit;
Edit5: TEdit;
Edit7: TEdit;
Edit6: TEdit;
Edit4: TEdit;
Label5: TLabel;
Label8: TLabel;
Label6: TLabel;
SpeedButton4: TSpeedButton;
Label7: TLabel;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
Label9: TLabel;
DBEdit1: TDBEdit;
Label10: TLabel;
Label11: TLabel;
DBEdit2: TDBEdit;
Label12: TLabel;
DBEdit3: TDBEdit;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Label18: TLabel;
Label19: TLabel;
DBEdit4: TDBEdit;
DBEdit5: TDBEdit;
DBEdit6: TDBEdit;
DBEdit7: TDBEdit;
DBEdit8: TDBEdit;
DBEdit9: TDBEdit;
DBEdit10: TDBEdit;
Label20: TLabel;
DBMemo1: TDBMemo;
Label21: TLabel;
Label22: TLabel;
Image1: TImage;
DBMemo2: TDBMemo;
Panel3: TPanel;
Panel5: TPanel;
Panel6: TPanel;
Panel7: TPanel;
DBNavigator1: TDBNavigator;
N9: TMenuItem;
N10: TMenuItem;
PageControl3: TPageControl;
ADOQuery1: TADOQuery;
TabSheet5: TTabSheet;
TabSheet6: TTabSheet;
Label23: TLabel;
Label24: TLabel;
Label25: TLabel;
Label26: TLabel;
Label27: TLabel;
Label28: TLabel;
Label29: TLabel;
Label30: TLabel;
Label31: TLabel;
Label32: TLabel;
DBEdit11: TDBEdit;
DBEdit12: TDBEdit;
DBEdit13: TDBEdit;
DBEdit14: TDBEdit;
DBEdit15: TDBEdit;
DBEdit16: TDBEdit;
DBEdit17: TDBEdit;
DBEdit18: TDBEdit;
DBEdit19: TDBEdit;
DBEdit20: TDBEdit;
Label33: TLabel;
DBMemo3: TDBMemo;
DBMemo4: TDBMemo;
procedure N7Click(Sender: TObject);
procedure N6Click(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure N10Click(Sender: TObject);
procedure SpeedButton6Click(Sender: TObject);
procedure SpeedButton5Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure PageControl1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form7: TForm7;

implementation
uses unit6,unit3;
{$R *.dfm}

procedure TForm7.N7Click(Sender: TObject);
begin
pagecontrol1.ActivePage:=tabsheet2;
if panel4.Visible=false then
panel4.Visible:=true
else
panel4.Visible:=false;
end;

procedure TForm7.N6Click(Sender: TObject);
begin
application.CreateForm(tform6,form6);
form6.ShowModal;
end;

procedure TForm7.N4Click(Sender: TObject);
begin
form6.Close;
form7.Close;
end;

procedure TForm7.N2Click(Sender: TObject);
begin
form3.showmodal;
end;

procedure TForm7.SpeedButton3Click(Sender: TObject);
begin
pagecontrol1.ActivePage:=tabsheet2;
if edit1.Text='' then
begin
MessageBox(handle,'请输入姓名,不能为空!','提示',MB_OK or MB_ICONINFORMATION);
exit;
end
else
begin
adoquery1.SQL.Clear;
adoquery1.Close;
adoquery1.sql.add('select *from 用户表 where 用户名='''+Edit1.Text+'''');
MessageBox(handle,'查询完毕!','提示',MB_OK or MB_ICONINFORMATION);
adoquery1.Open;
edit1.Text:='';
end;
end;


procedure TForm7.SpeedButton4Click(Sender: TObject);
var
sql:string;
begin
if (edit2.Text<>'')or (edit3.Text<>'')or (edit4.Text<>'')or (edit5.Text<>'')or (edit6.Text<>'')or (edit7.Text<>'')then
sql:='where (用户名 like'''+'%'+edit2.Text+'%'') or (联系地址 like'''+'%'+edit3.Text+'%'') or (联系电话 like'''+'%'+edit4.Text+'%'') or (邮政编码 like'''+'%'+edit5.Text+'%'') or (所在系别 like'''+'%'+edit6.Text+'%'') or (所在班级 like'''+'%'+edit7.Text+'%'')'
else
begin
application.messagebox('没有查询条件!','提示',mb_ok);
exit;
end;
ADOQuery1.Close ;
ADOQuery1.SQL.Clear ;
ADOQuery1.SQL.Add('select * from 用户表');
ADOQuery1.SQL.Add(sql);
ADOQuery1.Open ;
edit2.Text:='';
edit3.Text:='';
edit4.Text:='';
edit5.Text:='';
edit6.Text:='';
edit7.Text:='';
end;

procedure TForm7.SpeedButton1Click(Sender: TObject);
begin
if pagecontrol1.ActivePage=tabsheet1 then
begin
if dbgrid1.SelectedIndex>0 then
begin
adodataset1.Delete;
application.MessageBox('你已删除该用户的信息','删除提示',mb_ok);
end
else
application.MessageBox('没有用户可删除或没有选定要删除用户!','删除提示',mb_ok);
end;

if pagecontrol1.ActivePage=tabsheet2 then
begin
if dbgrid2.SelectedIndex>0 then
begin
adoquery1.Delete;
application.MessageBox('你已删除该用户的信息','删除提示',mb_ok);
end
else
application.MessageBox('没有用户可删除或没有选定要删除用户!','删除提示',mb_ok);
end;
end;

procedure TForm7.N10Click(Sender: TObject);
begin
pagecontrol1.ActivePage:=tabsheet1;
adodataset1.Refresh;
adodataset1.Close ;
adodataset1.CommandText:='select * from 用户表 ';
adodataset1.Open ;
application.MessageBox('已刷新','信息提示',mb_ok);
end;

procedure TForm7.SpeedButton6Click(Sender: TObject);
begin
if pagecontrol1.ActivePage=tabsheet1 then
begin
if (DBedit1.Text='')or(DBedit2.Text='')or(DBedit3.Text='') or (DBedit4.Text='')or (DBedit5.Text='')or (DBedit6.Text='')or (DBedit7.Text='')or (DBedit8.Text='')or (DBedit9.Text='')or (DBedit10.Text='')then
begin
application.MessageBox('信息不完整!','错误操作',mb_ok);
exit;
end
else
adodataset1.Prior;
end;
if pagecontrol1.ActivePage=tabsheet2 then
begin
if (DBedit11.Text='')or(DBedit12.Text='')or(DBedit13.Text='') or (DBedit14.Text='')or (DBedit15.Text='')or (DBedit16.Text='')or (DBedit17.Text='')or (DBedit18.Text='')or (DBedit19.Text='')or (DBedit20.Text='')then
begin
application.MessageBox('信息不完整!','错误操作',mb_ok);
exit;
end
else
adoquery1.Prior;
end;
end;

procedure TForm7.SpeedButton5Click(Sender: TObject);
begin
if pagecontrol1.ActivePage=tabsheet1 then
begin
if (DBedit1.Text='')or(DBedit2.Text='')or(DBedit3.Text='') or (DBedit4.Text='')or (DBedit5.Text='')or (DBedit6.Text='')or (DBedit7.Text='')or (DBedit8.Text='')or (DBedit9.Text='')or (DBedit10.Text='')then
begin
application.MessageBox('信息不完整!','错误操作',mb_ok);
exit;
end
else
adodataset1.Next;
end;
if pagecontrol1.ActivePage=tabsheet2 then
begin
if (DBedit11.Text='')or(DBedit12.Text='')or(DBedit13.Text='') or (DBedit14.Text='')or (DBedit15.Text='')or (DBedit16.Text='')or (DBedit17.Text='')or (DBedit18.Text='')or (DBedit19.Text='')or (DBedit20.Text='')then
begin
application.MessageBox('信息不完整!','错误操作',mb_ok);
exit;
end
else
adoquery1.Next;
end;
end;

function IsVaildEmailAddr(EmailAddr:String):boolean;
var
Number,I:integer; //Number用于给字符'@'计数
TempStr:String;
begin
TempStr:=EmailAddr;
Number:=0;
for I:=1 to Length(TempStr) do
begin
if (TempStr [I]='@') then
INC(Number);
end;

if ((Number =0)or(Number >1)) then
Result:=False//如果不含有字符'@',或者其个数大于1,则不合法
else
begin
if ((TempStr [1]='@')or (TempStr [length(TempStr)]='@')) then
Result:=False//如果字符'@'的位置在字符串开头或者末尾,则不合法
else
begin
I:=pos('@',TempStr);//获取字符'@'在字符串当中的位置
delete(TempStr,1,I);//获取字符串中字符'@'后面的剩余子串
if (Length(TempStr)<3) then
Result:=False //如果剩余子串的长度小于3,则不合法
else
begin
if ((pos('.',TempStr)=0)or(pos('.',TempStr)=length(TempStr))
or (pos('.',TempStr)=1))then
Result:=False//如果剩余的子串当中不含有字符'.',或者其位置在//子串的开头或者末尾,则不合法
else
Result:=True; //以上的判断都通过,则表示地址字符串为合法
end;
end;
end;
end;


procedure TForm7.SpeedButton2Click(Sender: TObject);
var
h,k,t,r:string;
begin

if pagecontrol1.ActivePage=tabsheet1 then
if dbgrid1.SelectedIndex>=0 then
begin
h:=DBedit2.Text;
k:=DBedit3.Text;
if (DBedit1.Text='')or(DBedit2.Text='')or(DBedit3.Text='') or (DBedit4.Text='')or (DBedit5.Text='')or (DBedit6.Text='')or (DBedit7.Text='')or (DBedit8.Text='')or (DBedit9.Text='')or (DBedit10.Text='')then
begin
application.MessageBox('信息不完整!','错误操作',mb_ok);
exit;
end
else
if h<>k then
begin
application.MessageBox('密码不匹配!','错误操作',mb_ok);
exit;
end
else
if not (IsVaildEmailAddr(DBEdit8.Text)) then
begin
ShowMessage('您输入的电子邮件地址格式不合法!');
exit;
end
else
adodataset1.Edit;
adodataset1.Post;
application.MessageBox('你已修改该用户的信息','修改提示',mb_ok);
end
else
application.MessageBox('没有用户可修改或没有选定要修改用户!','修改提示',mb_ok);

if pagecontrol1.ActivePage=tabsheet2 then
if dbgrid2.SelectedIndex>=0 then
begin
t:=DBedit12.Text;
r:=DBedit13.Text;
if (DBedit11.Text='')or(DBedit12.Text='')or(DBedit13.Text='') or (DBedit14.Text='')or (DBedit15.Text='')or (DBedit16.Text='')or (DBedit17.Text='')or (DBedit18.Text='')or (DBedit19.Text='')or (DBedit20.Text='')then
begin
application.MessageBox('信息不完整!','错误操作',mb_ok);
exit;
end
else
if t<>r then
begin
application.MessageBox('密码不匹配!','错误操作',mb_ok);
exit;
end
else
if not (IsVaildEmailAddr(DBEdit18.Text)) then
begin
ShowMessage('您输入的电子邮件地址格式不合法!');
exit;
end
else
adoquery1.Edit;
adoquery1.Post;
application.MessageBox('你已修改该用户的信息','修改提示',mb_ok);
end
else
application.MessageBox('没有用户可修改或没有选定要修改用户!','修改提示',mb_ok);

end;

procedure TForm7.PageControl1Change(Sender: TObject);
begin
if pagecontrol1.ActivePage=tabsheet1 then
begin
pagecontrol2.Visible:=true;
pagecontrol3.Visible:=false;
speedbutton1.Font.Color:=clpurple;
speedbutton2.Font.Color:=clpurple;
speedbutton3.Font.Color:=clpurple;
speedbutton5.Font.Color:=clpurple;
speedbutton6.Font.Color:=clpurple;
label1.Font.Color:=clpurple;
label2.Font.Color:=clpurple;
end
else
begin
pagecontrol3.Visible:=true;
pagecontrol2.Visible:=false;
speedbutton1.Font.Color:=clteal;
speedbutton2.Font.Color:=clteal;
speedbutton3.Font.Color:=clteal;
speedbutton5.Font.Color:=clteal;
speedbutton6.Font.Color:=clteal;
label1.Font.Color:=clteal;
label2.Font.Color:=clteal;
end

end;

搜索更多相关主题的帖子: Declaration found expected end file 
2007-06-13 13:48
anthony634
Rank: 6Rank: 6
来 自:西南交大
等 级:贵宾
威 望:24
帖 子:653
专家分:10
注 册:2006-6-8
得分:0 
最后面加个  end.
2007-06-13 13:53



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-147120-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017066 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved