How to sum values inserted in DataGridView cells in VB2010?
I have a problem on summing up two values inserted in specific cells in DGV.
This process happen during run time.
The result of summing should be display in another specific cell.
I have try the code below: Private Sub dgdTax_CellContentClick(ByVal
sender As System.Object, ByVal e As
System.Windows.Forms.DataGridViewCellEventArgs) Handles
dgdTax.CellContentClick
'======================================== CALCULATION
==============================================='
'to calculate r4rm1
Dim r2rm1 As Double
Dim r3rm1 As Double
Try
r2rm1 = CDbl(dgdTax(1, 2).Value)
Catch e1 As Exception
MessageBox.Show(e1.Message)
Exit Sub
End Try
Try
r3rm1 = CDbl(dgdTax(1, 3).Value)
Catch e2 As Exception
MessageBox.Show(e2.Message)
Exit Sub
End Try
dgdTax(1, 4).Value = r2rm1 + r3rm1
End Sub
But it didnt work. It shows message error "Conversion from type DBNull to
type Double is not valid."
What should I do? Pls help.
No comments:
Post a Comment