Working with Task Costs

To estimate the cost of a project, tasks are associated with costs. Aspose.Tasks for C++ API supports this feature of Microsoft Project with a range of properties.

Working with Task Cost

The Tsk exposes a number of properties for working with task cost:

Viewing Task Costs in Microsoft Project

To view task costs in Microsoft Project:

  1. On the Task Entry form, go to the Insert menu and select Columns.
  2. Add the cost columns.

Getting Task Costs

The following code example demonstrates how to get a task’s cost.

 1// Create new project
 2System::SharedPtr<Project> project = System::MakeObject<Project>();
 3    
 4// Add task and set cost
 5System::SharedPtr<Task> task = project->get_RootTask()->get_Children()->Add(u"Task");
 6task->Set<System::Decimal>(Tsk::Cost(), static_cast<System::Decimal>(800));
 7    
 8// Display cost related properties of task
 9System::Console::WriteLine(task->Get<System::Decimal>(Tsk::RemainingCost()));
10System::Console::WriteLine(task->Get<double>(Tsk::FixedCost()));
11System::Console::WriteLine(task->Get<double>(Tsk::CostVariance()));
12System::Console::WriteLine(project->get_RootTask()->Get<System::Decimal>(Tsk::Cost()));
13System::Console::WriteLine(project->get_RootTask()->Get<double>(Tsk::FixedCost()));
14System::Console::WriteLine(project->get_RootTask()->Get<System::Decimal>(Tsk::RemainingCost()));
15System::Console::WriteLine(project->get_RootTask()->Get<double>(Tsk::CostVariance()));
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.