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

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??

Comments

  • 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)
    Next
    Sharbell K. Mouess
Sign In or Register to comment.

Howdy, Stranger!

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

Categories

In this Discussion