Help please point out errors please. Condition: a 10x10 matrix is ​​specified in the DataGridView. It is necessary to determine the number of lines in which the sum of the elements is less than 10. Here is the code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i, j, s, k As Integer k = 0 For j = 0 To 9 s = 0 For i = 0 To 9 s = Val(A(0, i).Value) + Val(A(1, i).Value) + Val(A(2, i).Value) + Val(A(3, i).Value) + Val(A(4, i).Value) + Val(A(5, i).Value) + Val(A(6, i).Value) + Val(A(7, i).Value) + Val(A(8, i).Value) + Val(A(9, i).Value) If s < 10 Then k = k + 1 End If Next i Next j TextBox1.Text = k 
  • @Pawa_S is something elusively reminiscent of @Mary - DreamChild

1 answer 1

Try this:

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i, j, s, k As Integer k = 0 For j = 0 To 9 s = 0 For i = 0 To 9 s += Val(A(j, i).Value) Next i If s < 10 Then k = k + 1 End If Next j TextBox1.Text = k 
  • Can I still ask? {s + = Val (A (j, i) .Value)} what does it mean + =? - Pawa_S
  • + = is an operator of adding to the current value of a variable, i.e. if a = 5, then after a + = 6 the variable a will become equal to 11 - etki