Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Pliz help me sum contents of a datagrid view column in vb 2005

nziokinzioki Member Posts: 1
I have a column in datagrid that displays all the prices. I want to sum up all the values from all the rows of that column and display it as a label. How can I sum up the data??


  • SharbellMouessSharbellMouess Member Posts: 7
    Dim s As Double = 0 'sum result
    Dim colNum As Integer 'column number (zero-based)
    'dgvData is your DataGridView
    For Each r As DataGridViewRow In dgvData.Rows
    colNum = 0 'first column
    s += Val(r.Cells.Item(colNum).Value)
    Sharbell K. Mouess
Sign In or Register to comment.