title: SSRS Custom Code Loop
body: <p>Can any one of you please explain me how the loop (For, While) loops works in here</p>
  
  <pre><code>A      B
  Apple  13
  Grape  5
  Orange 16  
  </code></pre>
  
  <p>I have written this code, but it's not working here.</p>
  
  <pre><code>Public Function SafeConvert(ByVal num As String) As String
  
  Dim S as Integer
  For i as Integer = 0 to 2
    s += num
  next
  Return s
  
  End Function
  </code></pre>
  
  <p>Instead of adding each number, SSRS is adding only the last cell 16 * 3 times and showing incorrect result.</p>
  
  <p>And can you please answer this question as well. </p>
  
  <p>I have a matrix whose text box contains 3 values, how do I calculate the sum of all the values for <code>Q27_A_1</code> if the value is less than 5?</p>
  
  <p><img src="https://i.stack.imgur.com/mDa5n.png" alt="1"></p>