ComponentOne True DBInput Pro 8.0
Tutorial 13 - Using TDBDTCalcX with TDBHolidayX

This tutorial shows how the TDBDTCalcX object can be used with the TDBHolidayX object.

  1. Start a new project.

  2. From the Visual Basic Project menu, select References, then check the box labeled ComponentOne True DBDateCalcX 8.0 and ComponentOne True DBHolidayX 8.0 Click OK to add the TDBDTCalcX and TDBHolidayX objects to the project.

  3. Place a ListBox (lstDetail) and a Command button (cmdCalc) on the form (Form1) as shown in the following figure.

  4. We will use code to calculate the financial information which is displayed to the ListBox.

    Example Title
    Copy Code
    ' Process this event to display detail info for the schedule
    
    Sub cmdCalc_Click()
    
     
    
        ' Make an instance of the TDBDTCalcX object
    
        Dim objcalc As New TDBDTCalcX6Lib.TDBDTCalcX
    
        Dim HolidayMgr  As New TDBHolidayX
    
     
    
        Dim StartDate   As Date
    
        Dim m_1stPhs, m_2ndPhs, m_3rdPhs
    
        Dim n1stTotal   As Double
    
        Dim n2ndTotal   As Double
    
        Dim n3rdTotal   As Double
    
     
    
        ' Setup the weekend rests.
    
        ' Sunday rest all weeks.
    
        HolidayMgr.WeekRests(1) = -1       
    
     
    
        ' Second and Forth Saturday are rest.
    
        HolidayMgr.WeekRests(7) = 2 Or 4   
    
       
    
        StartDate = "1998/2/15"
    
     
    
        With objcalc
    
     
    
            ' Set how many days make up a month and how many hours make up a day.
    
            .DaysPerMonth = 20
    
            .HoursPerDay = 24
    
     
    
            ' Initialize the amount of days to zero.
    
            .InitValue
    
     
    
            ' Add the amount of time required for the 1st phase tasks.
    
            ' 10 days for designing.
    
            .CalcValue 10, dbiCalcDays  
    
     
    
            ' 5 days for reviewing the design.
    
            .CalcValue 5, dbiCalcDays   
    
     
    
            ' 10 days to document.
    
            .CalcValue 10, dbiCalcDays  
    
     
    
            n1stTotal = .GetTotals(dbiTtDays)
    
     
    
            ' Include the starting day.
    
            m_1stPhs = HolidayMgr.DaysFromNow(StartDate, n1stTotal - 1, dbiWorkdays)
    
     
    
            ' Add the amount of time required for the 2nd phase tasks.
    
            ' 2 months and 10 days for development.
    
            .CalcValue 2, dbiCalcMonths 
    
            .CalcValue 10, dbiCalcDays
    
     
    
            ' 15 days for testing.
    
            .CalcValue 15, dbiCalcDays  
    
     
    
            n2ndTotal = .GetTotals(dbiTtDays) - n1stTotal
    
            m_2ndPhs = HolidayMgr.DaysFromNow(m_1stPhs + 1, n2ndTotal, dbiWorkdays)
    
     
    
            ' Add the amount of time required for the 3rd phase tasks.
    
            ' 10 days for manual work.
    
            .CalcValue 10, dbiCalcDays  
    
     
    
            ' 5 days for the final touch up.
    
            .CalcValue 5, dbiCalcDays    
    
     
    
             n3rdTotal = .GetTotals(dbiTtDays) - (n1stTotal + n2ndTotal)
    
    m_3rdPhs = HolidayMgr.DaysFromNow(m_2ndPhs + 1, n3rdTotal, dbiWorkdays)
    
        End With
    
     
    
        ' Display the result to the list box.
    
        With lstDetail
    
            .AddItem String(40, "-")
    
            .AddItem "Schedule for the True DBInput Project:"
    
            .AddItem "1st phase:"
    
            .AddItem vbTab & StartDate & " - " & m_1stPhs
    
            .AddItem "2nd phase:"
    
            .AddItem vbTab & HolidayMgr.DaysFromNow(m_1stPhs, 1, dbiWorkdays) & " - " & m_2ndPhs
    
            .AddItem "3rd phase:"
    
            .AddItem vbTab & HolidayMgr.DaysFromNow(m_2ndPhs, 1, dbiWorkdays) & " - " & m_3rdPhs
    
            .AddItem "Total Required Days: " & objcalc.GetTotals(dbiTtDays)
    
        End With
    
        Set objcalc = Nothing
    
    End Sub
    

Run the program and observe the following:

When you click the command button, the following results will be displayed in the list box:

This concludes Tutorial 13.

 

 


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

Product Support Forum  |  Documentation Feedback