Hi, I’m running into a problem with the following code. Column 1 is correctly summed. However, the summed total of Column2 is the combined total of Column 1 and Column 2. I can’t see why the total of Column 1 is rolling over into Column 2. I’d greatly appreciate it if someone could tell me what I;ve done wrong, or what is missing.
Thank you
// Column 1
Dim i As Integer
Dim total As Double
For i=0 To ExpensesLB.LastRowIndex
total=total+Val(ExpensesLB.Cell(i, 1))
Next
// Column 1
Dim i As Integer
Dim total As Double
//here total is 0
For i=0 To ExpensesLB.LastRowIndex
total=total+Val(ExpensesLB.Cell(i, 1))
Next
//here total = sum of Column1
txtTotal.Text = Format(total, "###,###,##0.00")
ExpensesLB.Cell(44,1) = txtTotal.text
ExpensesLB.CellAlignmentAt(44,1) = ListBox.Alignments.Right
//you many need to do
total = 0
//here, as total still has the total of column1
// Column2
For i=0 To ExpensesLB.LastRowIndex
total=total+Val(ExpensesLB.Cell(i, 2))
Next
//here you sum column2 and added to total that has the total of column 1
txtTotal.Text = Format(total, "###,###,##0.00")
ExpensesLB.Cell(44,2) = txtTotal.text
ExpensesLB.CellAlignmentAt(44,2) = ListBox.Alignments.Right