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
|
procedure TForm1.Button2Click(Sender: TObject);
var
i :integer;
cal1,cal2,cal3,resul: double;
NbNotes: Integer;
const
COL_N1 = 5;
COL_N2 = 6;
COL_N3 = 7;
COL_TOT = 9;
COL_MOY = 11;
begin
with TEleve do
begin
for i := 1 to RowCount-1 do
begin
// Nombre de notes de l'élève
NbNotes := 0; cal1 := 0; cal2 := 0; cal3 := 0;
if TryStrToFloat(Cells[COL_N1, i], cal1) then Inc(NbNotes);
if TryStrToFloat(Cells[COL_N2, i], cal2) then Inc(NbNotes);
if TryStrToFloat(Cells[COL_N3, i], cal3) then Inc(NbNotes);
// Si NbNotes alors elève 'absent'
if (NbNotes = 0) then
begin
televe.Cells[9,i]:= 'abs';
televe.Cells[11,i] := 'abs';
end
else
begin
resul := cal1+cal2+cal3;
televe.Cells[COL_TOT,i]:= Format('%2.2f', [resul]);
televe.Cells[COL_MOY,i] := Format('%2.2f', [resul/NbNotes]);
end;
end;
end;
end; |
Partager