MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Trapping Bad Routes in VB6

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 ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-18-2004
Winwaed's Avatar
Mapping-Tools.com
Red Belt
 
Join Date: Feb 2004
Posts: 893
Blog Entries: 10
Trapping Bad Routes in VB6

I haven't done much VB6 programming, so this might be something simple in VB6; but I haven't found anything on the web yet, my book on VB is <expletive deleted>, and a better book is still in the mail!

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 10-18-2004
Winwaed's Avatar
Mapping-Tools.com
Red Belt
 
Join Date: Feb 2004
Posts: 893
Blog Entries: 10
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 10-18-2004
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 2,472
Blog Entries: 1
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
__________________
~ Now taking orders for MapPoint 2009 ~
~
~ Upgrade to MapForums Plus membership ~
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 10-18-2004
Winwaed's Avatar
Mapping-Tools.com
Red Belt
 
Join Date: Feb 2004
Posts: 893
Blog Entries: 10
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 10-18-2004
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 2,472
Blog Entries: 1
Working with MapPoint interactively, it does eventually pop up a message. I don't know enough about Windows programming to know what to look for if it's possible to detect what MapPoint is detecting when it pops up message..

Eric
__________________
~ Now taking orders for MapPoint 2009 ~
~
~ Upgrade to MapForums Plus membership ~
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
bad, routes, trapping, vb6


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

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


All times are GMT -5. The time now is 12:16 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54