title: calculation error vb.net textbox
body: <p>I am working with inventory system, Transaction form I had mainly 2 text box, first 1 is avaqty its from database available qty, other textbox is avqty from user adding qty.</p>
  
  <p>When user add qty avaqty textbox automatically change to 
  (avaqty) -(avqty) but as an example 10-10 result come in -1</p>
  
  <p>My code is:</p>
  
  <pre><code>Public Class transaction
  Dim objcon As New connectionclass
  
  Dim qty As String
  Public Function getqty() As String
      If itemid.Text = "" Then
      Else
          Try
              objcon.myconnection.Open()
              Dim getqty1 As New OleDbCommand("select balance from avaqty where item_id=" &amp; itemid.Text &amp; "", objcon.myconnection)
              Dim reader As OleDbDataReader = getqty1.ExecuteReader
              While reader.Read
                  qty = reader("balance")
              End While
              objcon.myconnection.Close()
          Catch ex As Exception
              MsgBox(ex.Message)
          End Try
  
      End If
      Return qty
  End Function
  Private Sub itemid_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles itemid.KeyPress
      If Asc(e.KeyChar) = 13 Then
          objcon.myconnection.Open()
          Try
  
              Dim getdata As New OleDbCommand("select*from itemtbl where item_id=" &amp; itemid.Text &amp; "", objcon.myconnection)
              Dim reader As OleDbDataReader = getdata.ExecuteReader
              While reader.Read
  
                  itemdesc.Text = reader("item_des").ToString
                  yom.Text = reader("unit_of_mesure").ToString
                  cost.Text = reader("item_cost").ToString
  
              End While
  
          Catch ex As Exception
              MsgBox(ex.Message)
          End Try
          objcon.myconnection.Close()
      End If
      If getqty() = 0 Then
          avaqty.Text = 0
      Else
          avaqty.Text = getqty()
      End If
  End Sub
  
  
  
  Private Sub initem_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles initem.CheckedChanged
      dataview.DataSource = GETDATA()
  End Sub
  
  Private Sub outitem_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles outitem.CheckedChanged
      dataview.DataSource = GETDATA2()
  End Sub
  
  Private Sub avqty_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles avqty.TextChanged
      Try
          If avqty.Text = "" Then
              avaqty.Text = getqty()
          Else
  
              avaqty.Text = CDbl(avaqty.Text - avqty.Text)
          End If
      Catch ex As Exception
          MsgBox(ex.Message)
      End Try
  
  End Sub
  
  Private Sub avaqty_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles avaqty.TextChanged
      If avaqty.Text &lt; 0 Then
          MsgBox("not inough qty")
          avqty.Clear()
      End If
  End Sub
  End Class
  </code></pre>