我想通过键盘输入数据,将包括学号,姓名,数学,语文,电子等学生成绩数据输入到一个顺序文件中(stu.dat)。下面是代码,请大家帮忙看下错在哪,什么只能新建,但没能把输入的数据保存到文件中,请高手们帮忙该该,我在这先谢谢大家了!!
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
GroupBox1: TGroupBox;
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
type
studentrecord=record
xh,xm:string;
xb:string;
sx,yy,dz:string;
end;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var t:studentrecord;
f:file;
begin
with t do
begin
xh:=edit1.Text;
xm:=edit2.text;
if radiobutton1.Checked=true then
xb:='男'
else
xb:='女';
sx:=edit3.text;
yy:=edit4.text;
dz:=edit5.text;
end;
assignfile(f,'e:/stu.dat');
rewrite(f);
closefile(f);
end;
end.