Hello, I need to count how many rows got a specific text in Column1.
It looks like it works but the number is still 1, but there are more rows with this text. It looks like it doesn't count +1 for every row. How to do that?
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
Dim count As Int32 = 0
For Each row As DataGridViewRow In DataGridView1.Rows
If row.Cells("Column1").Value = ("CountMe") Then
count += 1
End If
Exit For
Next
CountLabel.Text = count
If (count > 0) Then
MessageBox.Show("Exist!")
Else
MessageBox.Show("Nothing here!")
End If
End Sub
Thanks.