19-12-19, 08:28 PM
20-12-19, 12:09 AM
اثناء بحثي وجدت طريقتين لكي تعم الفائدة
كود :
' الطريقة 1
textBoxAvg.Text = (From row As DataGridViewRow In dataGridView1.Rows
Where row.Cells(2).FormattedValue.ToString() <> String.Empty
Select Convert.ToInt32(row.Cells(2).FormattedValue)).Average().ToString()
' الطريقة 2
Dim avg As Double
Dim sum As Integer
For i As Integer = 0 To dataGridView1.Rows.Count() - 1 Step +1
sum = sum + dataGridView1.Rows(i).Cells(2).Value
Next
avg = sum / dataGridView1.Rows.Count()
textBoxAvg.Text = avg.ToString("00.000")
End Sub
End Class