Hi,
I'm trying to loop through a column of checkboxes to see how many checked values there are in that column. The user has to have 2; no more, no less than 2, otherwise an error should show up.
The error message still occurs when I have only 2 chosen in that column. I even tried this code:Code:Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim count As Integer = 0
Dim x As Integer = 0
For x = 1 To DataGridView1.RowCount - 1
If CBool(DataGridView1.Rows(x).Cells(7).Value) Then
count = count + 1
End If
Next
If count = 2 Then
Me.Close()
Else
MsgBox("Error.")
e.Cancel = True
End If
End Sub
Code:If CBool(DataGridView1.Rows(x).Cells(7).Value = Checkstate.checked) Then

