Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Question about sum a column in dataGrip view

$
0
0
Hello
i'm trying to get the total of a Specific column
i've tried this code
Dim Profit As Integer = 0
        Dim counter As Integer
        For counter = 0 To (DataGridView1.Rows.Count - 1)
            If Not DataGridView1.Rows(counter).Cells("Amount").Value Is Nothing Then
                If Not DataGridView1.Rows(counter).Cells("Amount").Value.ToString().Length = 0 Then
                    Profit += Integer.Parse(DataGridView1.Rows(counter).Cells("Amount").Value.ToString())
                End If
            End If
        Next
        TextBox6.Text = Profit

this code working well if the datagridview is empty
but if i'm using this code with the exist info then an error occurred
"input string is not in a correct format"
any ideas??

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>