View Full Version : Has anyone had any problems setting the value of t....

12-12-2001, 02:38 AM
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?

Walt Cygan
12-12-2001, 02:38 AM
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")



Set objRoute = Nothing

Set objMap = Nothing

Exit Sub


Resume ExitSub

End Sub

This worked perfectly.

- Walt Cygan (http://www.mp2kmag.com/author.asp?id=9)

10-26-2006, 08:43 AM
You must first add two waypoints before you can set preferred departure.