0
Private Sub CalculateDeductionPer()

    Dim FixSumPer As Double

    Dim i As Integer
    If DataGridView1.Rows(i).Cells(9).Value Is Nothing = True Then
        For i = 0 To Me.DataGridView1.RowCount - 1
            FixSumPer += DataGridView1.Rows(i).Cells(9).Value
        Next
        i = i + 1
    End If


    Deduction.Text = FixSumPer

End Sub


this is my code to sum some cols in data grid but if some of cell = null all total of  FixSumPer = 0 , how i can fix this to get all sum 
3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Gé48
0

add 0 to FixSumPer if null using
IIf(IsDBNull(DataGridView1.Rows(i).Cells(9).Value), 0, DataGridView1.Rows(i).Cells(9).Value))

0

This works for me.

For i = 0 To DataGridView1.CurrentRow.Index
            sum1 = sum1 + DataGridView1.Rows(i).Cells("Column1").Value
Next i
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.