Thank you for replying.
You are right, when I use the code in a new project it executes as expected.
I am using the code within a datagridview's RowStateChanged event as I would like to make calculations every time a cell value is changed.
I have already accomplished this with a sub procedure, but now would like to do it with a function.
The sub executes as expected using the sub,
but I would like to increase the cell value and result automatically.
The sub and function below.
Code:
Private Sub search()
tot = 0
For Each r As DataGridViewRow In SkeduleringDataGridView.Rows.Cast(Of DataGridViewRow)().Where(Function(row) row.Visible = True)
If IsNumeric(r.Cells(15).Value) Then
tot += Val(r.Cells(15).Value)
End If
Next
TOTALMA1.Text = tot.ToString()
End Sub
Private Function somvirdag(ByVal r As Integer) As Decimal
tot = 0
For Each ry As DataGridViewRow In SkeduleringDataGridView.Rows.Cast(Of DataGridViewRow)().Where(Function(row) row.Visible = True)
If IsNumeric(ry.Cells(r).Value) Then
tot += Val(ry.Cells(r).Value)
End If
Next
Return tot
End Function
Regards