掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
StringGridでの平均算出 (ID:47505)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
いまいちよくわかりませんが、こんな感じでしょうか? procedure TForm1.SpeedButton1Click(Sender: TObject); var iw, iwCount: Word; sl, slAve: Single; begin sl := 0; iwCount := 0; for iw := 0 to Pred(StringGrid1.RowCount) do begin if Trim(StringGrid1.Cells[0, iw]) <> '' then begin sl := sl + StrToFloat(StringGrid1.Cells[0, iw]); inc(iwCount); end; end; slAve := sl / iwCount; showmessage(FloatToStr(slAve)); end; procedure TForm1.FormCreate(Sender: TObject); begin StringGrid1.Cells[0, 0] := '1'; StringGrid1.Cells[0, 1] := ''; StringGrid1.Cells[0, 2] := '22'; StringGrid1.Cells[0, 3] := ''; StringGrid1.Cells[0, 4] := '333'; end;
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.