pinem1
02-15-2007, 11:52 PM
I have been using the following code to help me determine the distances between stores. It works great, but I want to be more accurate and I want to use Latitude and Longitude.
Can someone help me modify the code so I can bring in a latitude and longitude for each of the two locations and then have it tell me the distance between the two?
Function MPRouteDist(iMPType As Integer, ParamArray WPoints())
Dim objApp As New MapPoint.Application
Set objMap = objApp.ActiveMap
With objMap.ActiveRoute
For Each wpoint In WPoints
.Waypoints.Add objMap.FindResults(wpoint).Item(1)
Next
.Waypoints.Item(1).SegmentPreferences = iMPType
.Calculate
MPRouteDist = Application.Round(CStr(.Distance), 5)
End With
objMap.Saved = True
End Function
A little bonus help as well. Is there a way to take the same information and have Mappoint tell me the minutes it would take to drive between the two locations?
Any and all help is greatly appreciated! Thanks
Can someone help me modify the code so I can bring in a latitude and longitude for each of the two locations and then have it tell me the distance between the two?
Function MPRouteDist(iMPType As Integer, ParamArray WPoints())
Dim objApp As New MapPoint.Application
Set objMap = objApp.ActiveMap
With objMap.ActiveRoute
For Each wpoint In WPoints
.Waypoints.Add objMap.FindResults(wpoint).Item(1)
Next
.Waypoints.Item(1).SegmentPreferences = iMPType
.Calculate
MPRouteDist = Application.Round(CStr(.Distance), 5)
End With
objMap.Saved = True
End Function
A little bonus help as well. Is there a way to take the same information and have Mappoint tell me the minutes it would take to drive between the two locations?
Any and all help is greatly appreciated! Thanks