title: Vb.net Simple TextBox conversion to integer gives error input string was not in a correct format
body: <p>I have some text boxes on a form I would like to validate.  I want to confirm that they contain only numbers, and that the "total" text box is equal to the sum of the other boxes:</p>
  
  <pre><code>Protected Sub TotalBoxValidator_ServerValidate(source As Object, args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles TotalBoxValidator.ServerValidate
      If ((Convert.ToInt32(Box1.Text) + Convert.ToInt32(Box2.Text) + Convert.ToInt32(Box3.Text) + Convert.ToInt32(Box4.Text) + Convert.ToInt32(Box5.Text) + Convert.ToInt32(Box6.Text) + Convert.ToInt32(Box7.Text)) = Convert.ToInt32(TotalBox.Text)) Then
          args.IsValid = True
      Else
          args.IsValid = False
      End If
  End Sub
  </code></pre>
  
  <p>Now during testing, I fill out the boxes with only integers.  The total box is automatically updated to be the sum of the other boxes.  However, when I click my "Submit" button on the form, and all the validators run, this one does not work properly.  </p>
  
  <p>The code throws an error on the first if statement, saying that the input to the Convert.ToInt32 calls is invalid.  "input string was not in a correct format".  I am positive that I am putting integers in each box, and that my TotalBox is equal to the sum of the other boxes.  So I'm kind of stuck on why this would throw an error.  <strong>Perhaps I am doing my conversion from string to integer wrong?</strong>  </p>
  
  <p>Does anyone have any idea what is going on here?  </p>