how to Add column cell value to previos cell value and get result

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fager elsaba7
    New Member
    • May 2015
    • 1

    #1

    how to Add column cell value to previos cell value and get result

    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
    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
    Last edited by Rabbit; May 2 '15, 08:45 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
Working...