Hi everyone, im new to this fourm. Ok i'm working on a dgv page, every time i fill out my text boxes ect. i press add transaction button i got.
Information shows up in the dgv, but then theres 2 columns i want to have the total sum show up in 2 seperate textboxes everytime i hit the add transaction button.
I got 2 seperate check boxes plus the 2 seperate textboxes.The one check box is for income the other is for expense. Same with the columns.
If i fill cells 5 first then also cells 4 it works fine.But then if i try to go back to filling out cell5 i get an error` total += Convert.ToDouble(DataGridView1.Rows(i).Cells(4).Value)
Hope this makes enough sense so somone can help. Thnaks!
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If ExRB.Checked Then
DataGridView1.Rows.Add(DateTimePicker1.Text, ComboBox1.Text, TextBox5.Text, TextBox6.Text, "", TextBox.Text)
Dim total As Double = 0
For index As Integer = 0 To DataGridView1.RowCount - 1
If Not IsDBNull(DataGridView1.Rows(index).Cells(5).Value) Then
total += Convert.ToDouble(DataGridView1.Rows(index).Cells(5).Value)
End If
Next
Label11.Text = total.ToString
ElseIf InRB.Checked Then
DataGridView1.Rows.Add(DateTimePicker1.Text, ComboBox1.Text, TextBox5.Text, TextBox6.Text, TextBox.Text)
Dim total As Double = 0
For i As Integer = 0 To DataGridView1.RowCount - 1
total += Convert.ToDouble(DataGridView1.Rows(i).Cells(4).Value)
Next
Label10.Text = total.ToString
End If
ComboBox1.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox.Text = ""
End Sub