📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Edit2: TEdit;
RadioGroup1: TRadioGroup;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
Button1: TButton;
Button3: TButton;
ListBox1: TListBox;
Label4: TLabel;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
type
Tongxun=record
name:string[8];
sex:string[2];
phone:string[13];
end;
var
Ton:array of Tongxun;
count:integer;
f:file of Tongxun;
procedure TForm1.FormCreate(Sender: TObject);
begin
count:=0;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
count:=count+1;
setlength(Ton,count);
with Ton[count-1] do
begin
if edit1.text='' then
begin
label3.Caption:='姓名不能为空!' ;
count:=count-1;
end
else
begin
name:=edit1.Text;
if RadioGroup1.ItemIndex=0 then
sex:='女'
else
sex:='男';
phone:=edit2.Text;
label3.Caption:='';
label3.Caption:='第'+inttostr(count)+'条记录添加完毕。';
end;
end;
edit1.Text:='';
edit2.Text:='';
end;
procedure TForm1.Button3Click(Sender: TObject);
var
i:integer;
s:string;
begin
ListBox1.Items.Clear;
for i:=low(Ton) to High(Ton) do
begin
s:='姓名:'+Ton[i].name+' '+'性别:'+Ton[i].sex+' '+'电话:'+Ton[i].phone;
ListBox1.Items.Add(s);
end;
label3.Caption:='';
label3.Caption:='一共有'+inttostr(count)+'条记录';
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -