Share via


RouteAfterOptimize event

Occurs after the stops on the route have been optimized.

Applies to

Objects: Map, MappointControl

Syntax

object.RouteAfterOptimize(Rte)

Part

Description

object

An expression that evaluates to a Map or MappointControl object.

Rte

Route object. The route for which properties were changed. Is always the same as the ActiveRoute property of the Map object. (For the MappointControl object, the ActiveRoute property can be accessed through the ActiveMap property.)

Remarks

  • For information about optimizing the stops on a route, see the Optimize the stops on your route procedure topic.

  • Do not make this event infinitely recursive by calling itself or causing itself to be called.

Example

  Dim WithEvents objApp As MapPoint.Application
  Dim WithEvents objMap As MapPoint.Map
  Dim objRoute As MapPoint.Route

  Private Sub Command1_Click()
    'Create a route and optimize it
    With objRoute.Waypoints
      .Add objMap.FindResults("Seattle, WA").Item(1)
      .Add objMap.FindResults("Redmond, WA").Item(1)
      .Add objMap.FindResults("Tacoma, WA").Item(1)
      .Add objMap.FindResults("Bellevue, WA").Item(1)
    End With
    objRoute.Waypoints.Optimize
  End Sub

  Private Sub Form_Load()
    'Set up the application
    Set objApp = CreateObject("mappoint.application")
    Set objMap = objApp.ActiveMap
    Set objRoute = objMap.ActiveRoute
    objApp.Visible = True
    objApp.UserControl = True
  End Sub

  Private Sub objMap_RouteAfterOptimize(ByVal Rte As MapPoint.Route)
    MsgBox "The route has been optimized."
  End Sub

Note   This sample code is specifically for use in MapPoint North America; it is for illustration purposes only.