Spread Windows Forms 8.0 Product Documentation > Developer's Guide > Getting Started > Tutorial: Creating a Checkbook Register > Adding Formulas to Calculate Balances |
Your checkbook register is now set up to look like a checkbook register; however, it does not balance the currency figures you enter in the register. This step sets up the formula for balancing the figures.
C# |
Copy Code
|
---|---|
// Set formula for calculating balance. fpSpread1.Sheets[0].ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.R1C1; int i; for (i = 0; i <= fpSpread1.ActiveSheet.RowCount - 1; i++) { if (i == 0) fpSpread1.Sheets[0].Cells[i, 7].Formula = "RC[-1] - RC[-2]" ; else fpSpread1.Sheets[0].Cells[i, 7].Formula = "RC[-1] - RC[-2] + R[-1]C"; } |
VB |
Copy Code
|
---|---|
' Set formula for calculating balance. FpSpread1.Sheets(0).ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.R1C1 Dim i As Integer For i = 0 To FpSpread1.ActiveSheet.RowCount - 1 If i = 0 Then FpSpread1.Sheets(0).Cells(i, 7).Formula = "RC[-1] - RC[-2]" Else FpSpread1.Sheets(0).Cells(i, 7).Formula = "RC[-1]-RC[-2]+R[-1]C" End If Next |
Review the list of steps for Tutorial: Creating a Checkbook Register.