Hi,
1. Table structure
ID Item Quantity Rate Remark
1 Coke 20 35 Nothing
2 Chips 12 10 Nothing
3 Item1 45 40 Nothing
4 Item2 60 78 Nothing
5 Item3 40 112 Nothing
2. Lets Bind it in a grid, add a new column name Total next to Rate column, calculate Total = quantity * rate.
3. To bind the grid use datatable as
Dim conn As New OleDb.OleDbConnection
Dim da As New OleDb.OleDbDataAdapter
Dim dt As New DataTable
da = New OleDb.OleDbDataAdapter("Select * from Temp", conn)
da.Fill(dt)
3. Add a new column next to Rate column as -
Dim cl As New DataColumn
cl = dt.Columns.Add("Total")
cl.SetOrdinal(4)
4. Calculation Part
Dim Rate As Integer
Dim Quanity As Integer
Dim Total As Integer
For i As Integer = 0 To dt.Rows.Count - 1
Quanity = CInt(dt.Rows(i)(2))
Rate = CInt(dt.Rows(i)(3))
Total = Quanity * Rate
dt.Rows(i)(4) = Total
Next
5. Data binding
DataGridView1.DataSource = dt
Done.