鱼C论坛

 找回密码
 立即注册
查看: 2613|回复: 0

求助一个关系读取的问题

[复制链接]
发表于 2012-3-24 22:43:17 | 显示全部楼层 |阅读模式
2鱼币
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Buttons;
type
  TForm1 = class(TForm)
    LabeledEdit1: TLabeledEdit;
    LabeledEdit2: TLabeledEdit;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    Edit1: TEdit;
    Edit2: TEdit;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
type
  Lady = Record
      num: Integer;
      name: String[20];
      end;
  Var
    VLady: File of Lady;
    h: Lady;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
Var
s: String;
begin
  GetDir(0,s);
  AssignFile(VLady,s + '\file.dat');
  if FileExists(s + '\File.dat') then
    Reset(VLady)
  Else
    Rewrite(VLady);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
CloseFile(VLady);
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
  if Edit2.Text = '' then
  begin
  ShowMessage('请先填写内容');
  Exit
  end
  Else
  h.num := StrToInt(Edit1.text);
  h.name := Edit2.Text ;
  Seek(VLady,FileSize(VLady));
  Write(VLady,h);
  Edit1.Text := '';
  Edit2.Text := '';
  ShowMessage('录入成功');
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
Var
  s: Integer;
begin
//ShowMessage(IntToStr(FileSize(VLady)));
  for s := 0 to FileSize(VLady) - 1 do
    begin
    Seek(Vlady,0);
    while not Eof(VLady) do
    begin
     Read(VLady,h);
     Edit1.Text := IntToStr( h.num );
     Edit2.Text := h.name ;
     end;
     end;
end;
end.


只能读出最后一个数。求高手解决下。

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-12-23 13:23

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表