Community of VE/MapPoint Users and Developers
This is a discussion on Trapping Bad Routes in VB6 within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; I haven't done much VB6 programming, so this might be something simple in VB6; but I haven't found anything on ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Trapping Bad Routes in VB6 I am using VB6 to calculate routes. I have done this before in C++. When MapPoint is asked to calculate an impossible route, it throws an exception. Real examples I've seen are: waypoints on different continents (usually an input error); and a farm that is on 1 mile of road that is connected to the national road network with a track which isn't in MapPoint's routing database. With an exception, I can easily trap this in C++ with a try ... catch block. How do I perform something like this in VB? This program must do something more intelligent that throwing a system error, and for this case I can save an "impossible to compute" value/setting. Richard
__________________ Winwaed Software Technology LLC http://www.winwaed.com See http://www.mapping-tools.com for MapPoint Tools Pre-Order MapPoint 2009 today: http://www.mapping-tools.com/mappoint2009 |
| ||||
|
Found the solution! (I said my book was bad!) The trick is to use the On Error construct, eg: Code: Public Sub CalculateRoute()
On Error GoTo Calc_Error
' my code here
myRoute.Calculate
' more code here
Calc_Exit:
Exit Sub
Calc_Error:
' code here to mark the route as invalid
Resume Calc_Exit
End Sub
Richard
__________________ Winwaed Software Technology LLC http://www.winwaed.com See http://www.mapping-tools.com for MapPoint Tools Pre-Order MapPoint 2009 today: http://www.mapping-tools.com/mappoint2009 |
| ||||
|
I found this doesn't work when there's a bad route and you try to Optimize.. although every stop may test out OK using Calculate, Optimize may still fail and I can't trap it. Check out the Programming Challenge in the latest newsletter:- http://www.mp2kmag.com/update/mappoi...-30/#challenge Of course if you don't need to Optimize it is not an issue.. Eric
__________________ |
| ||||
|
No I don't need to optimise! Hanging is difficult to trap, unlike an exception which can be trapped in any decent language. Richard
__________________ Winwaed Software Technology LLC http://www.winwaed.com See http://www.mapping-tools.com for MapPoint Tools Pre-Order MapPoint 2009 today: http://www.mapping-tools.com/mappoint2009 |
![]() |
| Tags |
| bad, routes, trapping, vb6 |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Multiple routes | Anonymous | MapPoint 2006/2009 Discussion | 2 | 03-23-2005 02:11 PM |
| More routes in the same map | Anonymous | MapPoint 2006/2009 Discussion | 1 | 03-09-2005 10:09 AM |
| exporting routes | Anonymous | MapPoint 2006/2009 Discussion | 2 | 10-12-2002 11:20 PM |
| Routes | Anonymous | Wish List | 1 | 09-03-2002 11:24 PM |
| I need to add bus routes to a map. What are my bes.... | Anonymous | MapPoint 2006/2009 Discussion | 1 | 10-26-2001 10:41 AM |