PDA

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



Anonymous
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")

objRoute.Calculate

ExitSub:

Set objRoute = Nothing

Set objMap = Nothing

Exit Sub

ErrSub:

Resume ExitSub

End Sub


This worked perfectly.


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

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