[RESOLVED] Datagridview Average
This one should be fairly easy (I hope)...
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim tot As Integer = 0
For i As Integer = 0 To DataGridView1.RowCount - 1
If DataGridView1.Rows(i).Cells(1).Value = txtName.Text Then
tot += DataGridView1.Rows(i).Cells(5).Value
End If
Next
If tot = 0 Then
MsgBox("No Records Found")
End If
txtTotal.Text = tot
End Sub
What I need help with is how to expand this code to have it average the total sum this code calculates by the number of entries it added. Basically I need it to count how many different entries it added to get that total and use that number to average.
You guys have been a big help so far, thanks and I hope I can get along on my own for a while once this is done!