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

Delphi Sources



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

 
 
Опции темы Поиск в этой теме Опции просмотра
  #3  
Старый 30.10.2011, 11:51
cyber922 cyber922 вне форума
Новичок
 
Регистрация: 07.10.2011
Сообщения: 77
Версия Delphi: Turbo Delphi 20
Репутация: 10
Восклицание

Код:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Buttons, StdCtrls, Grids;
 
type
  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    Edit1: TEdit;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    Edit2: TEdit;
    BitBtn1: TBitBtn;
    Label1: TLabel;
    Edit3: TEdit;
    Button2: TButton;
    Label2: TLabel;
    procedure SpeedButton1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
 type
zap= record
NZ : string[6]; {номер записи}
fam: s15; {фамилия студента}
ball:array [1..3] of integer;{массив оценок по трем предметам}
end;
var
  Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.FormCreate(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.BitBtn1Click(Sender: TObject);
begin
Close;
end;
 
procedure TForm1.Button2Click(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.


Странно, у меня (f8), тут не ругается не на что. всё пропускает..
Ещё такой момент, как пишется функция которая при нажатии распечатывает на принтере..?

Десять раз код пересмотрел, вроде ниче криминального...



p.s. где написанно в описании записи "st15" не обращайите внимания, это я исправлю потом...
Ответить с цитированием
 


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

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

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

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


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


 

Сайт

Форум

FAQ

Соглашения

Прочее

 

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