Try
Me.StockTableAdapter.FillBy(Me.PosDbDataSet.Stock, BarcodeTextBox.Text)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
ltotal.Text = Val(ItemPriceTextBox.Text) * Val(QuantityTextBox.Text)
Me.DataGridView1.Rows.Add(ItemNameTextBox.Text, ItemPriceTextBox.Text, QuantityTextBox.Text, ltotal.Text)
Dim i As Integer
Dim total As Decimal
For i = 0 To DataGridView1.Rows.Count - 1
total = Val(TbxToAmount.Text) + Val(DataGridView1.Item("column4", i).Value) ' or you can use Cint
Next
TbxToAmount.Text = total
BarcodeTextBox.Text = ""
ItemNameTextBox.Text = ""
ItemPriceTextBox.Text = ""
QuantityTextBox.Text = ""
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If DataGridView1.SelectedRows.Count > 0 Then
Dim ta As New DataTable
For i As Integer = DataGridView1.SelectedRows.Count - 1 To 0 Step -1
DataGridView1.Rows.RemoveAt(DataGridView1.SelectedRows(i).Index)
Next
Else
MsgBox("No Order Items are Selected")
End If
End Sub