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??

New Topic/Question
Reply



MultiQuote



|