|
|
Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
|
Опции темы | Поиск в этой теме | Опции просмотра |
#1
|
|||
|
|||
Типизированные файлы [delphi]
Вообщем тут такая проблема,по заданию я сделал код.
Код:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, StdCtrls, Buttons, ExtCtrls; type TForm1 = class(TForm) StringGrid1: TStringGrid; BitBtn1: TBitBtn; ComboBox1: TComboBox; ComboBox2: TComboBox; ComboBox3: TComboBox; ComboBox4: TComboBox; Button1: TButton; ComboBox5: TComboBox; ComboBox6: TComboBox; Panel1: TPanel; Edit2: TEdit; Label1: TLabel; Button2: TButton; Edit1: TEdit; Label2: TLabel; Label3: TLabel; Edit3: TEdit; Button3: TButton; Button4: TButton; Button5: TButton; procedure FormCreate(Sender: TObject); procedure BitBtn1Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Button5Click(Sender: TObject); private { Private declarations } public { Public declarations } end; type zap=record fio : string[10]; km:string[10]; mark.avto:string[50]; end; var Form1: TForm1; Z:zap; F:file of zap; k:integer; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin stringgrid1.DefaultColWidth:=75; stringgrid1.ColCount:=6; stringgrid1.RowCount:=6; stringgrid1.Cells[0,0]:='ФИО ' +#13+#10 +'сотрудника'; stringgrid1.Cells[2,0]:='km'; stringgrid1.Cells[3,0]:=' mark.avto '; k:=1; end; procedure TForm1.BitBtn1Click(Sender: TObject); begin Close; end; procedure TForm1.Button1Click(Sender: TObject); begin StringGrid1.Cells[0,k]:= ComboBox1.Text; StringGrid1.Cells[1,k]:= ComboBox2.Text; StringGrid1.Cells[2,k]:= ComboBox3.Text; StringGrid1.Cells[3,k]:= ComboBox4.Text;k:=k+1; Edit1.Text:=IntToStr(k); end; procedure TForm1.Button2Click(Sender: TObject); Var i,m:integer; begin m:=0; for i:=1 to k-1 do if (strtoint(stringgrid1.Cells[3,i]) >20) and (stringgrid1.Cells[1,i]='муж') then m:=m+1; Edit2.Text:=inttostr(m); end; procedure TForm1.Button3Click(Sender: TObject); var i:integer; begin AssignFile(F,Edit3.Text); rewrite(F); for i:=1 to k-1 do with Z do begin fio := stringgrid1.Cells[0,i]; km := stringgrid1.Cells[1,i]; mark.avto := strtoint(stringgrid1.Cells[2,i]); write(F,Z); end; closefile(F); end; procedure TForm1.Button4Click(Sender: TObject); var i:integer; begin for i:=1 to strToInt(Edit1.Text)-1 do begin stringgrid1.Cells[0,i]:=' '; stringgrid1.Cells[1,i]:=' '; stringgrid1.Cells[2,i]:=' '; end; end; procedure TForm1.Button5Click(Sender: TObject); begin AssignFile(F,Edit3.Text); reset(F); K:=1; while not eof(F) do begin read(F,z); stringgrid1.Cells[0,k]:=z.fio; stringgrid1.Cells[1,k]:=z.km; stringgrid1.Cells[2,k]:=inttostr(z. mark.avto); K:=K+1; end; closefile(F); end; end. Вот задание Цитата:
Проблема в том, что я не могу реализовать кнопку вычисления по заданию То бишь вот эту кнопку : Код:
procedure TForm1.Button2Click(Sender: TObject); Var i,m:integer; begin m:=0; for i:=1 to k-1 do if (strtoint(stringgrid1.Cells[3,i]) >20) and (stringgrid1.Cells[1,i]='муж') then m:=m+1; Edit2.Text:=inttostr(m); end; и вот ещё задачка: Цитата:
Я не пойму как её реализовать.(( Заранее всем спасибо. p.s. как пишется в delphi функция суммирования ? Цитата:
Последний раз редактировалось cyber922, 09.11.2011 в 10:51. |