For J As Integer = 0 To DataGridView1.ColumnCount = -1
For i As Integer = 0 To DataGridView1.Rows.Count = -2
For J As Integer = 0 To DataGridView1.ColumnCount - 1
For i As Integer = 0 To DataGridView1.Rows.Count - 2
A quicker way to solve this kind of issues is to use debugging; put a breakpoint at the beginning of the
block, start a debug session (F5), and execute line-by-line, watching for the program flow. You will quickly find out that your loops may not behave the way they should.