Форум по Delphi программированию

Delphi Sources



Вернуться   Форум по Delphi программированию > Все о Delphi > [ "Начинающим" ]
Ник
Пароль
Регистрация <<         Правила форума         >> FAQ Пользователи Календарь Поиск Сообщения за сегодня Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
  #1  
Старый 28.10.2011, 17:06
cyber922 cyber922 вне форума
Новичок
 
Регистрация: 07.10.2011
Сообщения: 77
Версия Delphi: Turbo Delphi 20
Репутация: 10
По умолчанию неработает код.

Код:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, StdCtrls, Buttons;

type
  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    Button1: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    procedure OnCreate(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
Close;
end;

procedure TForm1.OnCreate(Sender: TObject);
begin
 with   StringGrid1    do begin
  Cells[0,0] := '№/№';
  Cells[1,0] := 'Фамилия';
  Cells[2,0] := 'Математика';
  Cells[3,0] := 'Физика';
  Cells[4,0] := 'Химия';
  Cells[5,0] := 'Средний балл';
  ColCount:=6;  FixedCols:=0;

end;
  end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
Var i,j : Byte;
    F : File of Zap;
    S :Zap;
begin
 AssignFile(F, Edit1.Text);
  Rewrite(F);
  StringGrid1.RowCount:=StrToInt(Edit3.text);  
  For I := 1 to StringGrid1.RowCount-1  do  with  StringGrid1 do
  Begin
     S.NZ:= Cells[0,I];
     S.fam := Cells[1,I];
     S.ball[1]:=StrToInt( Cells[2,I]);
     S.ball[2]:=StrToInt( Cells[3,I]);
     S.ball[3]:=StrToInt( Cells[4,I]);
    Write(F,S)
  end;
  CloseFile(F)
end;


procedure TForm1.SpeedButton2Click(Sender: TObject);
Var I : Byte;
    F : File of Zap;
    S : zap;  Sr:real;
begin
   AssignFile(F, Edit2.Text);
  Reset(F); i:=1;  seek(F,0);
  while not eof(F) do 
  Begin
  read(F,S);
  StringGrid1.Cells[0,I]:=S.NZ;
  StringGrid1.Cells[1,I]:=S.fam;
  StringGrid1.Cells[2,I]:=IntToStr(S.ball[1]);
  StringGrid1.Cells[3,I]:=IntToStr(S.ball[2]);
  StringGrid1.Cells[4,I]:=IntToStr(S.ball[3]);
  SR:=(S.ball[1]+S.ball[2]+S.ball[3])/3;
  StringGrid1.Cells[5,I]:=FloatToStrF(SR,ffFixed,4,1); 
  i:=i+1;
  end;
  CloseFile(F)
end;


procedure TForm1.SpeedButton3Click(Sender: TObject);
var
i:integer;
begin
    for i:=1  to   StringGrid1.RowCount do begin
  StringGrid1.Cells[0,I]:=' ';
  StringGrid1.Cells[1,I]:=' ';
  StringGrid1.Cells[2,I]:=' ';
  StringGrid1.Cells[3,I]:=' ';
  StringGrid1.Cells[4,I]:=' ';
  StringGrid1.Cells[5,I]:=' ';
  end;

end;

end.
Админ: Пользуемся тегами для оформления кода!

Вообщем перестаёт работать код уже с этой команды : F : File of Zap; Чёт, причину по которой он не работает не могу найти...

Последний раз редактировалось Admin, 28.10.2011 в 17:13.
Ответить с цитированием
 


Delphi Sources

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать темы
Вы не можете отвечать на сообщения
Вы не можете прикреплять файлы
Вы не можете редактировать сообщения

BB-коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход


Часовой пояс GMT +3, время: 10:15.


 

Сайт

Форум

FAQ

Соглашения

Прочее

 

Copyright © Форум "Delphi Sources" by BrokenByte Software, 2004-2025