DrivingCost property
Returns or sets the fuel price or fixed cost for determining route costs, depending on the method set in the DrivingCostUnits property. Read/write Currency.
Applies to
Objects: DriverProfile
Syntax
object.DrivingCost
Parameters
Part | Description |
---|---|
object | Required. An expression that returns a DriverProfile object. |
Remarks
Set the method by which costs are calculated (DrivingCostUnits property) before setting the DrivingCost property, otherwise the value may be affected by a change in method.
To set fuel consumption rates, use the FuelConsumptionCity, FuelConsumptionHighway, and FuelConsumptionUnits properties.
Example
Sub SetDrivingCost()
Dim objApp As New MapPoint.Application
Dim objMap As MapPoint.Map
Dim objRoute As MapPoint.Route
'Set up the application
Set objMap = objApp.ActiveMap
Set objRoute = objMap.ActiveRoute
objApp.Visible = True
objApp.UserControl = True
'Add route stops and calculate the route
objRoute.Waypoints.Add objMap.FindResults("Seattle, WA").Item(1)
objRoute.Waypoints.Add objMap.FindResults("Redmond, WA").Item(1)
'Set the DrivingCostUnits to fixed cost based on distance and use DrivingCost to set the cost at $.80 per distance unit
objRoute.DriverProfile.DrivingCostUnits = geoCostBasedOnDistance
objRoute.DriverProfile.DrivingCost = 0.8
objRoute.Calculate
'Get new route cost
MsgBox "New route cost: $" + CStr(objRoute.Cost)
End Sub
Note This sample code is specific for use in MapPoint North America; it is for illustration purposes only.