this my code
iwant to add column cellvalue in datagridview to previouse number of cells user insert
the summ variable always equal zero
any help
iwant to add column cellvalue in datagridview to previouse number of cells user insert
the summ variable always equal zero
any help
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
year = TextBox1.Text
month = TextBox2.Text
noofmonths = TextBox3.Text
Dim summ As String
summ = 0
Dim rowindex As Integer
For Each row As DataGridViewRow In DataGridView1.Rows
If row.Cells.Item(1).Value = TextBox1.Text Then
If row.Cells.Item(2).Value = TextBox2.Text Then
rowindex = row.Index
For i As Integer = rowindex To noofmonths And i <> 0
summ = row.Cells.Item(3).Value + summ
rowindex = row.Index - 1
i = i - 1
Next
summ = summ / noofmonths.ToString
rowindex = rowindex + noofmonths
Dim actie As String = row.Cells(3).Value.ToString()
row.Cells(4).Value = summ
MsgBox(summ)
Else
MsgBox("Item not found")
End If
End If
Next