I want to do calculations based of user input.
I Can't do it?
I need to careful for something?
If I want to specify a column name at Select script I use column ID?
I have two columns, "OrderTotal" and "Tips"
I placed two Labels, lblTips and lblOrders, on the form.
(Look in your B4XTable Example in the ShowDialog sub for a hint)
This is what I do in the B4XTable1_DataUpdated sub:
B4X:
Dim rs As ResultSet = B4XTable1.sql1.ExecQuery("Select SUM(c7) From Data")
If rs.NextRow Then
If rs.GetString(rs.GetColumnName(0)) <> Null Then
totalOrders = rs.GetString(rs.GetColumnName(0))
Else
Return
End If
Dim rs As ResultSet = B4XTable1.sql1.ExecQuery("Select SUM(c8) From Data")
If rs.NextRow Then
totalTips = rs.GetString(rs.GetColumnName(0))
End If
End If
lblTips.Text = "Tips: $" & NumberFormat(totalTips,1,2)
lblOrders.Text = "Orders: $" & NumberFormat(totalOrders,1,2)
Nice example Jimmy: Could you have combined both transactions in one like this:
B4X:
Dim rs As ResultSet = B4XTable1.sql1.ExecQuery("Select SUM(c7) as SC7, SUM(c8) as SC8 From Data")
If rs.NextRow Then
lblTips.Text = "Tips: $" & NumberFormat(rs.GetDouble("SC7"),1,2)
lblOrders.Text = "Tips: $" & NumberFormat(rs.GetDouble("SC8"),1,2)
End If
Yes, I could have if I wasn't so lazy.
I added the second transaction a few days later and couldn't be bothered to optimize it at the time. App is still in development.
Good point, though!