ComponentOne True DBInput Pro 8.0
Tutorial 11 - Using TDBFinancialX

In this tutorial, you will learn how to use the TDBFinancialX object.

  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 = 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
    

Run the program and observe the following:

The List1 should return the values that are commented out in each section of code above.

This concludes Tutorial 11.

 

 


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

Product Support Forum  |  Documentation Feedback