Tutorials > Tutorial 11 - Using TDBFinancialX |
In this tutorial, you will learn how to use the TDBFinancialX object.
Start a new project.
From the Visual Basic Project menu, select References, then check the box labeled ComponentOne True DBFinancialX 8.0. Click OK to add the TDBFinancialX object to the project.
Place a ListBox (List1) on the form (Form1) as shown in the following figure.
We will use code to calculate the financial information that is displayed to the ListBox.
Example Title |
Copy Code
|
---|---|
Private Sub Form_Load() Dim objTax As New TDBFinancialX6Lib.TDBFinancialX Dim bRet As Boolean With objTax .Value = 1500 .TaxRate = 5.5 ' After Tax. .TaxType = dbiAfterTax .RateType = dbiRatePercentage .RoundType = dbiRound .RoundDigit = -2 bRet = .TaxCalc() If bRet Then List1.AddItem "Price: " & .Price List1.AddItem "Tax: " & .Tax List1.AddItem "Total: " & .Total List1.AddItem "----------------------" End If End With With objTax .Value = 1500 .TaxRate = 5.5 ' Pretax. .TaxType = dbiPreTax .RateType = dbiRatePercentage .RoundType = dbiRound .RoundDigit = -2 bRet = .TaxCalc() If bRet Then List1.AddItem "Price: " & .Price List1.AddItem "Tax: " & .Tax List1.AddItem "Total: " & .Total List1.AddItem "----------------------" End If End With With objTax .Value = 450.755 .TaxRate = 0.055 ' After Tax. .TaxType = dbiAfterTax ' Without percentage. .RateType = dbiRateNormal bRet = .TaxCalc() If bRet Then List1.AddItem "Price: " & .Price List1.AddItem "Tax: " & .Tax List1.AddItem "Total: " & .Total List1.AddItem "----------------------" End If End With ' If set to 1-Percentage, the tax calculation will be performed in percentage: With objTax .Value = 450.755 .TaxRate = 5.5 .TaxType = dbiAfterTax '- After Tax .RateType = dbiRatePercentage bRet = .TaxCalc() If bRet Then List1.AddItem "Price: " & .Price List1.AddItem "Tax: " & .Tax List1.AddItem "Total: " & .Total List1.AddItem "----------------------" End If End With ' If either the RoundType or the RoundDigit property is set to 0, or if the specified digit doesn't exist in the results, then the rounding will be ignored and not be processed. For example: With objTax .Value = 450.755 .RoundType = dbiRoundNone .RoundDigit = 0 .TaxRate = 5.5 .TaxType = dbiPreTax '- Pretax .RateType = dbiRatePercentage bRet = .TaxCalc() If bRet Then List1.AddItem "Price: " & .Price List1.AddItem "Tax: " & .Tax List1.AddItem "Total: " & .Total List1.AddItem "----------------------" End If End With End Sub |
The List1 should return the values that are commented out in each section of code above.
This concludes Tutorial 11.