Welcome to MapForums!

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

## Route between postcodes

This is a discussion on Route between postcodes within the Development forums, part of the MapPoint Desktop Discussion category; Hi all The code below calculates the driving and straight line distances between two UK postcodes correctly. But no route ...

1. Junior Member Yellow Belt
Join Date
Dec 2009
Posts
13

## Route between postcodes

Hi all

The code below calculates the driving and straight line distances between two UK postcodes correctly. But no route shown on the map. I will like to see the route shown on the map, please help if you can. Thanks.

The code:

Code:
```        MappointControl1.NewMap "c:\ccdmap\cleanmap.ptm"
Dim oMap As Mappoint.Map
Dim objLoc1 As Mappoint.Location
Dim objLoc2 As Mappoint.Location
Dim oPin As Mappoint.Pushpin
Label3.Caption = ""
Label4.Caption = ""
Label5.Caption = ""
Set oMap = GetObject(, "MapPoint.Application").ActiveMap
Set objRoute = oMap.ActiveRoute
objRoute.Clear
'Locate the 2 points
Set objLoc1 = oMap.FindAddressResults(, , , , "SE19 1JX", "UK")(1)
objLoc1.GoTo
Set objLoc2 = oMap.FindAddressResults(, , , , "SW16 2PN", "UK")(1)
objLoc2.GoTo
'Calculate the route
objRoute.Calculate

'Drive Distance in kms
Label3.Caption = "Driving Dist kms: " + Str(objRoute.Distance)
'Drive Time in minutes
Label4.Caption = "Driving Time mins: " + Str(objRoute.DrivingTime)
'Straight Line Distance in kms (as a check)
Label5.Caption = "Straight line dist kms: " + Str(oMap.Distance(objLoc1, objLoc2))

oMap.Saved = True
Set objApp = Nothing
Set oMap = Nothing
Set objLoc1 = Nothing
Set objLoc2 = Nothing
Set objRoute = Nothing```
ayo

2. Junior Member Yellow Belt
Join Date
Dec 2009
Posts
13

## Re: Route between postcodes

I have managed to sort the routing problem. Apparently i was not specifying the activemap correctly. The correct map for me was:

Set oMap = MappointControl1.ActiveMap

And that did it. Got the distances and the route displayed ok.

Thanks to you all.

ayo