Hi guys,
im having trouble summing up the column in my (unbound) datagridview, i can add to the DGV fine, but when trying to sum up a column it says "Input string was not in a correct format."
heres my code
Private Sub btn_Add_Click(sender As System.Object, e As System.EventArgs) Handles btn_Add.Click
DataGridView1.Rows.Add(cbox_Product.Text, tbox_Sale_Price.Text, tbox_Qty.Text, tbox_Discount.Text, tbox_SubTotal.Text)
If DataGridView1.Rows.Count > 0 Then
tbox_Gross.Text = total().ToString("c")
End If
End Sub
Private Function Total() As Double
Dim tot As Double = 0
Dim i As Integer = 0
For i = 0 To DataGridView1.Rows.Count - 1
tot += Convert.ToDouble(DataGridView1.Rows(i).Cells(4).Value)
Next i
Return tot
End Function
any ideas guys?
cheers :)