我有一段delphi代码,请高手能给我详细的解释,谢谢(争取每句都能翻译成中文)

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, Grids, DBGrids, StdCtrls, ExtCtrls;

type
TForm1 = class(TForm)
RadioGroup1: TRadioGroup;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
Table1: TTable;
Table1EmpNo: TIntegerField;
Table1LastName: TStringField;
Table1FirstName: TStringField;
Table1PhoneExt: TStringField;
Table1HireDate: TDateTimeField;
Table1Salary: TFloatField;
Edit2: TEdit;
procedure FormCreate(Sender: TObject);
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
procedure RadioButton3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
Checked:array [1..3]of boolean;
MinNo,MaxNo:integer;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
Edit2.Enabled:=False;
Table1.Open;
Table1.FindLast;
MaxNo:=Table1EmpNo.Value;
Table1.FindFirst;;
MinNo:=Table1EmpNo.Value;
end;

procedure TForm1.RadioButton1Click(Sender: TObject);
begin
RadioButton1.Checked:=True;
Showmessage('编号的最大范围为'+inttostr(MinNo)+'~'+inttostr(MaxNo));
end;

procedure TForm1.RadioButton2Click(Sender: TObject);
begin
RadioButton2.Checked:=True;
Showmessage('编号的最大范围为'+inttostr(MinNo)+'~'+inttostr(MaxNo));
end;

procedure TForm1.RadioButton3Click(Sender: TObject);
begin
RadioButton3.Checked:=True;
Edit2.Enabled:=True;
Showmessage('编号的最大范围为'+inttostr(MinNo)+'~'+inttostr(MaxNo)+';请分别输入!');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
if (not RadioButton1.Checked)and (not RadioButton2.Checked)and (not RadioButton3.Checked)then
begin
showmessage('请选择查询方式!');
Exit;
end;
if RadioButton1.Checked then
if Table1.FindKey([Edit1.Text]) then
showmessage('您要查询的记录已找到!') else
showmessage('对不起,没有您要查询的记录!');
if RadioButton2.Checked then
begin
Table1.FindNearest([Edit1.text]);
showmessage('已找到相关记录!');
end;
if RadioButton3.Checked then
begin
Table1.SetRange([Edit1.Text],[Edit2.Text]);
Edit2.Enabled:=False;
end;
end;

end.

{创建窗体自动生成的代码}
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, Grids, DBGrids, StdCtrls, ExtCtrls;

type

{这一段是注册控件,窗口中的所有空间在这里列出}
TForm1 = class(TForm)
RadioGroup1: TRadioGroup;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
Table1: TTable;
Table1EmpNo: TIntegerField;
Table1LastName: TStringField;
Table1FirstName: TStringField;
Table1PhoneExt: TStringField;
Table1HireDate: TDateTimeField;
Table1Salary: TFloatField;
Edit2: TEdit;

{空间的事件注册}
procedure FormCreate(Sender: TObject);
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
procedure RadioButton3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

{定义全局变量}
var
Form1: TForm1;
Checked:array [1..3]of boolean;
MinNo,MaxNo:integer;

implementation

{$R *.dfm}

{这个是当窗体被打开,但是没有进行任何动作之前,窗体要进行的操作}
procedure TForm1.FormCreate(Sender: TObject);
begin
Edit2.Enabled:=False;//文本框2可见,但不可编辑
Table1.Open;//表控件
Table1.FindLast;//表中数据的最后一行
MaxNo:=Table1EmpNo.Value;//将最后一行的编号给变量MaxNo
Table1.FindFirst;//表中数据的第一行
MinNo:=Table1EmpNo.Value;//将第一行的编号给变量MinNo

end;

{RadioButton1控件的单击事件}
procedure TForm1.RadioButton1Click(Sender: TObject);
begin
RadioButton1.Checked:=True;//RadioButton1控件设为选中状态
Showmessage('编号的最大范围为'+inttostr(MinNo)+'~'+inttostr(MaxNo));//弹出窗口提示,范围是上面赋值的MinNo到MaxNo,IntToStr是字符串类型转换成整型
end;

{同RadioButton1Click}
procedure TForm1.RadioButton2Click(Sender: TObject);
begin
RadioButton2.Checked:=True;
Showmessage('编号的最大范围为'+inttostr(MinNo)+'~'+inttostr(MaxNo));
end;

{同RadioButton1Click}
procedure TForm1.RadioButton3Click(Sender: TObject);
begin
RadioButton3.Checked:=True;
Edit2.Enabled:=True;//文本框2设置为可编辑状态
Showmessage('编号的最大范围为'+inttostr(MinNo)+'~'+inttostr(MaxNo)+';请分别输入!');
end;

{button按钮控件单击事件}
procedure TForm1.Button1Click(Sender: TObject);
begin
if (not RadioButton1.Checked)and (not RadioButton2.Checked)and (not RadioButton3.Checked)then//判断如果RadioButton1,2,3同事没有被选中时
begin
showmessage('请选择查询方式!');//弹出窗口提示
Exit;//直接跳出,下面代码不再执行
end;
if RadioButton1.Checked then //如果RadioButton1被选中了
if Table1.FindKey([Edit1.Text]) then//如果选中状态下,文本框1中内容在表数据中找到了,提示记录找到,否则提示没找到
showmessage('您要查询的记录已找到!') else
showmessage('对不起,没有您要查询的记录!');
if RadioButton2.Checked then
begin
//同上,如果找到提示找到记录
Table1.FindNearest([Edit1.text]);
showmessage('已找到相关记录!');
end;
if RadioButton3.Checked then
begin
//如果RadioButton3被选中,在表中查找文本框1和文本框2的值之间的数据
Table1.SetRange([Edit1.Text],[Edit2.Text]);
Edit2.Enabled:=False;//文本框2不可编辑状态
end;
end;

end.

建议打开Delphi自己写一个,马上就明白了
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-06-12
晕,没必要了吧,很多代码都是delphi环境给自动生成的。
procedure TForm1.RadioButton1Click(Sender: TObject);
像上面这种类似的函数都是按钮的点击事件。
不理解可以问我,不过建议还是自己多看看书。书上都写的很明白。
看书之后还可以一劳永逸。
第2个回答  2010-06-12
谷歌翻译结果如下:
单位组1;

接口

使用
窗口,邮件,sysutils的,变体,类,图形,控件,窗体,
对话,数据库,DBTables,网格,DBGrids,StdCtrls,ExtCtrls;

类型
TForm1 =类(TForm)
RadioGroup1:TRadioGroup;
RadioButton1:TRadioButton;
RadioButton2:TRadioButton;
RadioButton3:TRadioButton;
Button1的:TButton;
Edit1:t编辑;
Label1的:TLabel;
DBGrid1:TDBGrid中;
DataSource1:TDataSource;
表一:TTable;
Table1EmpNo:TIntegerField;
Table1LastName:TStringField;
Table1FirstName:TStringField;
Table1PhoneExt:TStringField;
Table1HireDate:TDateTimeField;
Table1Salary:TFloatField;
Edit2:t编辑;
程序FormCreate(发件人:TObject);
程序RadioButton1Click(发件人:TObject);
程序RadioButton2Click(发件人:TObject);
程序RadioButton3Click(发件人:TObject);
程序Button1Click(发件人:TObject);
私人
()私人声明
公众
公开声明)(
结束;

变种
Form1中:TForm1;
检查时间:数组[1 .. 3]布尔;
明诺,MaxNo:整数;

实施

($?*. dfm)

程序TForm1.FormCreate(发件人:TObject);
开始
Edit2.Enabled:=虚假;
Table1.Open;
Table1.FindLast;
MaxNo:= Table1EmpNo.Value;
Table1.FindFirst;;
明诺:= Table1EmpNo.Value;
结束;

程序TForm1.RadioButton1Click(发件人:TObject);
开始
RadioButton1.Checked:=真;
Showmessage(编号的最大范围为+ inttostr(明诺)+~+ inttostr(MaxNo));
结束;

程序TForm1.RadioButton2Click(发件人:TObject);
开始
RadioButton2.Checked:=真;
Showmessage(编号的最大范围为+ inttostr(明诺)+~+ inttostr(MaxNo));
结束;

程序TForm1.RadioButton3Click(发件人:TObject);
开始
RadioButton3.Checked:=真;
Edit2.Enabled:=真;
Showmessage(编号的最大范围为+ inttostr(明诺)+~+ inttostr(MaxNo)+;请分别输入!);
结束;

程序TForm1.Button1Click(发件人:TObject);
开始
如果(不RadioButton1.Checked)和(不RadioButton2.Checked)和(不RadioButton3.Checked),则
开始
showmessage(请选择查询方式!);
退出;
结束;
然后,如果RadioButton1.Checked
如果Table1.FindKey([Edit1.Text]),则
showmessage(您要查询的记录已找到!)其他
showmessage(对不起,没有您要查询的记录!);
然后,如果RadioButton2.Checked
开始
Table1.FindNearest([Edit1.text]);
showmessage(已找到相关记录!);
结束;
然后,如果RadioButton3.Checked
开始
Table1.SetRange([Edit1.Text],[Edit2.Text]);
Edit2.Enabled:=虚假;
结束;
结束;

结束。

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网