title: Loops - Adding Numbers - Visual Basic
body: <p>So the program has to add all the numbers from "x" to "y". </p>
  
  <p>But it also has to display all the numbers added :</p>
  
  <p>i.e. 10 to 20 should display 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 = 165 </p>
  
  <p>Here's what I have:</p>
  
  <pre><code>Dim firstnum As Integer = Val(TextBox1.Text)
      Dim secondnum As Integer = Val(TextBox2.Text)
      Dim sum As Integer = 0
  
  
      While firstnum &lt;= secondnum
  
          sum = sum + firstnum
          firstnum = firstnum + 1
  
          Label3.Text = firstnum &amp; "+"
  
      End While
  
  
      suum.Text = "  =  " &amp; Val(sum)
  </code></pre>