Top |
Post New Question |
Read All |
MP2K Asks Microsoft
538
stuart
-
December 12, 2001
Has anyone had any problems setting the value of the PreferredDeparture property in the Waypoint object? I was having problems with this a while ago, but the situation was more complicated because I was using Borland's C++ Builder. I have now re-written my code using the standard IDispatch interface, but changes to PreferredDeparture are just ignored. Unfortunately, I don't have access to a copy of VB so I'm still using C++. My code does work with MapPoint 2001 but not 2002. Has anyone tried setting PreferredDeparture in a VB application?
Answer:
I tried the following code in a VB app with the MapPoint ActiveX control called "ctlMapPoint" and a Command button called "cmdTest":
Private Sub cmdTest_Click()
On Error GoTo ErrSub
Dim objMap As MapPointCtl.Map
Dim objRoute As MapPointCtl.Route
'Set up the application
Set objMap = ctlMapPoint.ActiveMap
Set objRoute = objMap.ActiveRoute
'Add two waypoints to the map
objRoute.Waypoints.Add objMap.FindResults("Seattle, WA").Item(1)
objRoute.Waypoints.Add objMap.FindResults("Spokane, WA").Item(1)
'Set the time you'd like depart from the start point
objRoute.Waypoints.Item(1).PreferredDeparture = TimeValue("8:00:00 AM")
objRoute.Calculate
ExitSub:
Set objRoute = Nothing
Set objMap = Nothing
Exit Sub
ErrSub:
Resume ExitSub
End Sub
This worked perfectly.
- Walt Cygan
Post New Answer / Follow-up