I want my code to affect column 5 and 6 to, but everytime i add it i get an error this is wat i have so far

Private Sub DataGridView1_CellEndEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit

    If (e.ColumnIndex = 4) Then   ' Checking numeric value for Column4 only
        Dim value As String = DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value.ToString()
        For Each c As Char In value
            If Not Char.IsDigit(c) Then
                MessageBox.Show("Please enter a numeric value.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = String.Empty
                Exit Sub
            End If
    End If
End Sub

i figured it out using else if

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.