title: Search in a two-dimensional array
body: <p>I'm trying to find the values in different points of the array. When I run the code, it always goes to <code>The value doesn't exists</code>, also I  do not know how to count the values that are same <code>r</code>.</p>
  <pre><code>    r = 0 
      c = txtbbus.Text
      For i = 0 To n - 1
          For j = 0 To n - 1
              If a(i, j) = c Then
                  txtbres.Text = &quot;The value exists &quot; &amp; r &amp; &quot; and it's in the position (&quot; &amp; i &amp; &quot;, &quot; &amp; j &amp; &quot;) &quot;
              Else
                  txtbres.Text = &quot;The value doesn't exists&quot;
              End If
          Next j
      Next i
  </code></pre>
  <p>And this is how I initialize <code>a</code>:</p>
  <pre><code>    txtbmatriz.Text = &quot;&quot;
      For i = 0 To n - 1
          For j = 0 To n - 1
              a(i, j) = CInt((100 * Rnd()) + 1)
              txtbmatriz.Text += a(i, j) &amp; &quot; &quot;
              m += a(i, j)
              l += 1
          Next j
          txtbmatriz.Text += vbCrLf
      Next i
  </code></pre>