私は1000データポイントを含むDataGridViewを持っています。私は正常に私のDataGridViewの値の最小、最大、および平均を計算しましたが、今、私は、特定の範囲からの最小値、最大値、平均値を取得したい。たとえば、101〜200または201〜300のデータ。Datagridview、特定の範囲で最小、最大、平均を取得する方法
For i As Integer = 0 To dataGridView1.Rows.Count() - 1 Step +1
sum_tmp = sum_tmp + dataGridView1.Rows(i).Cells(2).Value
If i = 0 Then
max_tmp = dataGridView1.Rows(i).Cells(2).Value
min_tmp = dataGridView1.Rows(i).Cells(2).Value
End If
If max_tmp < dataGridView1.Rows(i).Cells(2).Value Then
max_tmp = dataGridView1.Rows(i).Cells(2).Value
End If
If min_tmp > dataGridView1.Rows(i).Cells(2).Value Then
min_tmp = dataGridView1.Rows(i).Cells(2).Value
End If
Next
avg_tmp = sum_tmp/dataGridView1.Rows.Count()
上記の値を取得するコードです。私は、コンボボックスを選択することによって変更された整数変数を使用しようとしましたが、常にminに0の値を取得します。悲しいことに、それは平均で正しい値を示しています。どのように間違っているのでしょうか?
'Filter関数 'を使用し、' Betweenメソッド'を使用して 'DataView'を使用して値を取得できますか? DataTable.FIlter()メソッドでGoogle検索を実行する – MethodMan
合計または平均を計算するときはいつですか?コンテキストメニュー項目の行とクリックをユーザーが選択していますか? –
@AlexB。あなたは良い質問をする。私は2つの単一の値(最初の行、最後の行) – djv