Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

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

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 5 of 5

Trapping Bad Routes in VB6

This is a discussion on Trapping Bad Routes in VB6 within the MapPoint Desktop 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 ...

  1. #1
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60

    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

  2. #2
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60
    Found the solution! (I said my book was bad!)
    The trick is to use the On Error construct, eg:

    Code:
    Public Sub CalculateRoute&#40;&#41;
        On Error GoTo Calc_Error
    
        ' my code here
    
        myRoute.Calculate
    
        ' more code here
    
    Calc_Exit&#58;
        Exit Sub
        
    Calc_Error&#58;
        ' 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

  3. #3
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4
    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
    ~ Order MapPoint MapPoint 2013 Here and Get Free Access to the MapForums Downloads ~
    ~~
    ~ Upgrade to Get Access to the MapForums Downloads ~

  4. #4
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60
    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

  5. #5
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4
    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
    ~ Order MapPoint MapPoint 2013 Here and Get Free Access to the MapForums Downloads ~
    ~~
    ~ Upgrade to Get Access to the MapForums Downloads ~

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Multiple routes
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 03-23-2005, 02:11 PM
  2. More routes in the same map
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 03-09-2005, 10:09 AM
  3. exporting routes
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 10-12-2002, 11:20 PM
  4. Routes
    By Anonymous in forum Wish List
    Replies: 1
    Last Post: 09-03-2002, 11:24 PM
  5. I need to add bus routes to a map. What are my bes....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 10-26-2001, 10:41 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


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