Help me please! Conditions of the problem: a 10x10 matrix should be created using a DataGridView. Determine the number of columns in which there is only one zero.

Here's what I got:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i, j, n, k As Integer n = A.Rows.Count - 1 k = 0 For j = 0 To 9 If A(j, i).Value = 0 Then k = k + 1 End If Next TextBox1.Text = k End Sub 

Right or Not?

    1 answer 1

    You have the wrong code. It is necessary to rewrite something like this:

     l=0 For i = 0 to 9 k=0 For j = 0 To 9 If A(j, i).Value = 0 Then k = k + 1 End If Next j if(k=1)then l=l+1 end if Next i TextBox1.Text = l 
    • You are my savior! Thank you so much. - KathyKate
    • @KathyKate 1. If the answer suits you, click on the check mark on the left side of the answer. The forum has a concept of% of accepted questions, so if it is low, then you can simply stop answering 2. The next time, formulate your questions more clearly - this time I edited, next time I will not. - Barmaley