用户自定义类型3
unit Unit1;interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
type
Fishoil=Record
name:String;
sex:String;
age:Integer;
end;
var
i:Integer=1;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
With StringGrid1 do
begin
cells:='姓名';
cells:='性别';
cells:='年龄';
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
fishc1:Fishoil;
begin
if i<6 then
begin
fishc1.name :=InputBox('昵称','请输入'+IntToStr(i)+'个账号的昵称 ','');
fishc1.sex :=InputBox('性别','请输入'+IntToStr(i)+'个账号的性别 ','');
fishc1.age :=StrToInt(InputBox ('年龄','请输入'+IntToStr(i)+'个账号年龄 ',''));
With StringGrid1 do
begin
cells:=fishc1.name;
cells:=fishc1.sex;
cells:=IntTOStr(fishc1.age);
end;
Inc(i);
end
Else
ShowMessage('数据已满,请清空后重新输入');
end;
procedure TForm1.Button2Click(Sender: TObject);
var
i,j:Integer;
begin
For i:=1 to 5 do
begin
For j:=0 to 2 do
begin
StringGrid1.cells:='';
end;
end;
end;
end.
页:
[1]