Hi. so this is actually a continuation from another question of mineHere but i was advised to start a new thread as the original question was already answered.
This is the result of previous question answered :
code for the listbox - datagridview interaction
At the top of the code so its public
Dim dt As New DataTable
in private sub form load
grd_order.DataSource = dt
in private sub for product list
Private Sub product_list(ByVal pid As String) Dim getproduct As String = "SELECT FLD_PRODUCT_ID,FLD_PRICE FROM TBL_PRODUCTS_A154287 WHERE FLD_PRODUCT_ID='" & pid & "'" Dim reader As New OleDb.OleDbDataAdapter(getproduct, myconnection) Dim getcolumns As String = "SELECT FLD_QTY,FLD_SUBTOTAL FROM TBL_ORDERITEM_A154287 WHERE FLD_PRODUCT_ID='" & pid & "'" Dim reader2 As New OleDb.OleDbDataAdapter(getcolumns, myconnection) reader.Fill(dt) reader2.Fill(dt) End Sub
Now i want to know how to calculate the subtotal? because user can key in the quantity of the product they want. like in the picture : CK005 | 850 | , quantity and subtotal cells are empty. how would i get the value from cell Price and cell Quantity? to calculate the subtotal :
Subtotal = valueFromQtyCell * valueFromPriceCell and put it into cell Subtotal for each its own row. Then get each value from column subtotal of each row and add them up as the Total Price;
TotalPrice = valueFromSubtotalCellOfEachRow this im assuming needs a loop?