ComponentOne True DBInput Pro 8.0
Tutorial 12 - Tax Calculations with TDBFinancialX

This tutorial shows how to use the TaxType property to determine whether the Value property represents the desired total after the tax is calculated thus yielding the pre-tax total, or whether it represents the pre-tax amount yielding an after-tax total when invoking the TaxCalc method. The results can be retrieved from the Price, Tax, and the Total properties.

  1. Start a new project.

  2. 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.

  3. Place a ListBox (List1) on the form (Form1) as shown in the following figure.

  4. 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 = 450.755
    
            .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
    
     
    
        ' If set to 1-After Tax, the Price property will return the Value property, the Tax property is calculated as (Value * (TaxRate / 100)), and the Total property is calculated as (Value + Tax).
    
     
    
        With objTax
    
            .Value = 450.755
    
            .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
    
    End Sub
    

Run the program and observe the following:

This concludes Tutorial 12.

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback