Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Delphi by vxvcxv ( 12 years ago )
procedure TForm1.cmdCalcMoyenneClick(Sender: TObject);
var
  tabTemp : TtabNotes;
begin
  txtMoyenne.Text := FloatToStr(CalculMoyenne(CopierNotesSelect(LstNoms, LstNotes, tabTemp), tabTemp));
end;

function CalculMoyenne(nbNombre : integer; var tabNotes : TtabNotes) : single;
var
  i,
  nombre : integer;
begin
  nombre := 0;
  for i := low(tabNotes) to high(tabNotes) do
    nombre := nombre + tabNotes[i];
  result := nombre / nbNombre;
end;

function CopierNotesSelect(ListeChNoms : TListBox; ListeChNotes : TListBox;
                                  var tableauNotes : TtabNotes) : integer;
var
  i,
  nbNotes : integer;
begin
  nbNotes := 0;
  if ListeChNoms.MultiSelect then
    begin
      for i := 0 to ListeChNoms.Count - 1 do
        if ListeChNoms.Selected[i] then
          begin
            tableauNotes[i] := StrToInt(ListeChNotes.Items.Strings[i]);
            inc(nbNotes);
          end;
    end;
  result := nbNotes;
end;

 

Revise this Paste

Your Name: Code Language: