Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

I am getting the above error in the following piece of code. The row of error is also highlighted:
VB
 	Dim Debittotal As Integer = 0
        Dim Credittotal As Integer = 0

        If grdDebit.RowCount > 1 Then
            For index As Integer = 0 To grdDebit.RowCount - 1
*****                Debittotal += Convert.ToDecimal(grdDebit.Rows(index).Cells(2).Value)
            Next
        End If

        If grdCredit.RowCount > 1 Then
            For index As Integer = 0 To grdCredit.RowCount - 1
                Credittotal += Convert.ToDecimal(grdCredit.Rows(index).Cells(2).Value)
            Next
        End If


        Dim NewfnBalance As Integer = Debittotal - Credittotal
Thanks in advance.
Posted
Updated 21-Feb-14 0:06am
v2

1 solution

This is telling you that you don't have three Cell elements. If I were you, I would put a breakpoint on the line that's causing the error and take a look at the values of grdDebit.Rows(index). I suspect the value you are after is in Cells(1).
 
Share this answer
 
Comments
atul sharma 5126 23-Feb-14 4:38am    
thanks a lot pete

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900