title: How to Subtract textbox value with datagridview column..VB
body: <p>I need help for my vb project. Last day I created stock database</p>
  
  <p>The database have 2 columns <code>Item Name</code> and <code>Quantity</code></p>
  
  <p>In my form I have two textboxes same as database and a button</p>
  
  <p>when button press</p>
  
  <ul>
  <li>if my "Itemname textbox" match with database column <code>itemname</code> then "Quantity Textbox" subtract with "Quantity column"</li>
  <li>if match with database "itemname column"[2] the column2 quantity subtract with "Quantitytextbox"</li>
  </ul>
  
  <p>Here's my Code it works but it's lengthy:</p>
  
  <pre><code>If itemname.Text = Me.DataGridView1.Rows(0).Cells(0).Value Then
              Me.DataGridView1.Rows(0).Cells(1).Value = CDbl(Me.DataGridView1.Rows(0).Cells(1).Value) - CDbl(quantity.Text)
              MsgBox("Data Saved SuccessFully")
              quantity.Text = ""
              itemname.Text = ""
  
          ElseIf itemname.text = Me.DataGridView1.Rows(1).Cells(0).Value Then
              Me.DataGridView1.Rows(1).Cells(1).Value = CDbl(quantity.Text) - CDbl(Me.DataGridView1.Rows(1).Cells(1).Value)
              MsgBox("Data Saved SuccessFully")
              quantity = ""
              itemname.Text = ""
  
          ElseIf itemname.Text = Me.DataGridView1.Rows(2).Cells(0).Value Then
              Me.DataGridView1.Rows(2).Cells(1).Value = CDbl(quantity.Text) - CDbl(Me.DataGridView1.Rows(2).Cells(1).Value)
              MsgBox("Data Saved SuccessFully")
              quantity = ""
              itemname.Text = ""
  
  
          ElseIf itemname.Text = Me.DataGridView1.Rows(3).Cells(0).Value Then
              Me.DataGridView1.Rows(3).Cells(1).Value = CDbl(quantity.Text) - CDbl(Me.DataGridView1.Rows(3).Cells(1).Value)
              MsgBox("Data Saved SuccessFully")
              quantity.Text = ""
              itemname.Text = ""
  
            endif
  end sub
  </code></pre>
  
  <p>And so on.......</p>
  
  <p>PLEASE HELP ....</p>