i have a form with datagridview like picture below :
![Posted Image]()
in calculate button, i use this code :
problem is, this formula

in calculate button, i use this code :
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim total1, total2 As Double For i As Integer = 0 To DataGridView1.Rows.Count - 1 total1 += DataGridView1.Rows(i).Cells(0).Value DataGridView1.Rows(i).Cells(3).Value = DataGridView1.Rows(i).Cells(1).Value * DataGridView1.Rows(i).Cells(2).Value / total1 total2 += DataGridView1.Rows(i).Cells(3).Value Next TextBox1.Text = total2 End Sub End Class
problem is, this formula
DataGridView1.Rows(i).Cells(3).Value = DataGridView1.Rows(i).Cells(1).Value * DataGridView1.Rows(i).Cells(2).Value / total1is only working for the last row with correct calculation, can anyone help please?