Ricerca dato, somma valore, gestione db null e gestione evento non compreso nell’indice
Dim Gc1 As Integer = 0 Dim Gc1a As Integer = 0 Dim Gc1b As Integer = 0 Dim Gc1c As Integer = 0 Dim Gc1d As Integer = 0 Dim Gc1e As Integer = 0 Dim Gc1f As Integer = 0 For i As Integer = 0 To DataGridView2.RowCount - 1 If DataGridView2.Rows(i).Cells(1).Value = DataGridView1.Rows(0).Cells(3).Value Then Gc1 += DataGridView2.Rows(i).Cells(7).Value Gc1a += DataGridView2.Rows(i).Cells(8).Value Gc1b += DataGridView2.Rows(i).Cells(9).Value Gc1c += DataGridView2.Rows(i).Cells(10).Value Gc1d += DataGridView2.Rows(i).Cells(11).Value Try Gc1e += DataGridView2.Rows(i).Cells(12).Value Gc1f += DataGridView2.Rows(i).Cells(13).Value Catch Ex As Exception End Try End If Next If Gc1 = 0 Then End If If Gc1a = 0 Then End If If Gc1b = 0 Then End If If Gc1c = 0 Then End If If Gc1d = 0 Then End If If Gc1e = 0 Then End If If Gc1f = 0 Then End If For i As Integer = 0 To DataGridView2.RowCount - 1 Try If DataGridView1.Rows(0).Cells(3).Value = DataGridView2.Rows(i).Cells(1).Value Then End If DataGridView1.Rows(0).Cells(5).Value = Gc1 DataGridView1.Rows(0).Cells(6).Value = Gc1a DataGridView1.Rows(0).Cells(7).Value = Gc1b DataGridView1.Rows(0).Cells(8).Value = Gc1c DataGridView1.Rows(0).Cells(9).Value = Gc1d DataGridView1.Rows(0).Cells(10).Value = Gc1e DataGridView1.Rows(0).Cells(11).Value = Gc1f Catch ex As Exception End Try NextCon questo codice gestisco tutte le funzioni riportate nel titolo del post, chiedo alla vs esperienza se può essere snellito e soprattutto la funzione e di ricerca e di somma la devo effettuare per ogni riga del dgv1 (in totale 12 righe) per cui al momento ripeto il codice per ogni riga (con le opportune correzioni) si può snellire anche questa procedura? Grazie