Top |
Post New Question |
Read All |
MP2K Asks Microsoft
558
chris
-
December 19, 2001
So how do i get it to calculate teh distance between two places on a form and return the distance and cost of travelling.
Answer:
The simplest way is to add waypoints, calculate a route and then use the cost and distance properties of the route. For example, from the VB reference:
Dim objApp As New MapPoint.Application
Dim objMap As MapPoint.Map
Dim objRoute As MapPoint.Route
'Set up 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)
objRoute.Calculate
'Output the total length and cost of the route
MsgBox "The route distance is: " + CStr(objRoute.Distance)
MsgBox "Cost of route: $" + CStr(objRoute.Cost)
- Walt Cygan
Post New Answer / Follow-up