Hey,
got a question regarding an error I get while debugging. I created a small form with a datagridview (1 row, 2 columns) with this code
after a few calculations I would like to update these values each time the user changes the value of a textbox. This is my code (not working - giving me an Index out of range error pointing to the first DataGridView line)
Well I am messed around a bit with this freakin error and got a solution but I don't know why this one is working without an error message
There is only 1 row so it's a bit strange I need a for loop...any idea why this one is working?
got a question regarding an error I get while debugging. I created a small form with a datagridview (1 row, 2 columns) with this code
Code:
DataGridView2.Rows.Add("0.0", "0.0")
Code:
If Val(TextBox2.Text) < 0.01 Or TextBox2.Text = "" Then
DataGridView2.Rows(0).Cells(0).Value = "0.0"
DataGridView2.Rows(0).Cells(1).Value = "0.0"
Else
mvorschub = TextBox2.Text
DataGridView2.Rows(0).Cells(0).Value = mvorschub
DataGridView2.Rows(0).Cells(1).Value = sbreite * DataGridView2.Rows(0).Cells(0).Value * kc * (DataGridView2.Rows(0).Cells(0).Value ^ -mc)
End If
Code:
If Val(TextBox2.Text) < 0.01 Or TextBox2.Text = "" Then
For i As Integer = 0 To DataGridView1.Rows.Count - 1
DataGridView2.Rows(0).Cells(0).Value = "0.0"
DataGridView2.Rows(0).Cells(1).Value = "0.0"
Next
Else
mvorschub = TextBox2.Text
DataGridView2.Rows(0).Cells(0).Value = mvorschub
DataGridView2.Rows(0).Cells(1).Value = sbreite * DataGridView2.Rows(0).Cells(0).Value * kc * (DataGridView2.Rows(0).Cells(0).Value ^ -mc)
End If