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 8 of 8

Writing files in a VB Addin?

This is a discussion on Writing files in a VB Addin? within the MapPoint Desktop Discussion forums, part of the Map Forums category; Sounds strange, but I'm having a lot of trouble writing to text files from a VB6 add-in. This is with ...

  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

    Writing files in a VB Addin?

    Sounds strange, but I'm having a lot of trouble writing to text files from a VB6 add-in. This is with MapPoint 2006, although I've also tried MP2004.

    The problem is occasional, but sufficiently common that if I'm writing a hundred lines of text then it will occur in either the first 'run' of my add-in or a re-run.

    MapPoint 2006 itself appears to give the problem, and I get the XP message about reporting information to Microsoft. I've tried trapping errors in my file writing code - no luck.

    I've tried commenting a lot of the code out so that only an open# and close# occur - still have the crashes!
    (commenting ALL the file code fixes the problem, as does exporting to Excel)

    I was initially using the "old school Basic" open# and close#, but also tried the modern FileSystemObject/TextStream api. This also gave the same problem.

    Thinking back, I think this might be the only VB6 addin that I've written for MapPoint that writes to a text file! All the others usually write to Access or Excel via their COM interfaces.
    So I checked the help file incase I missed something - a known restriction (like the non-modal dialog boxes). Can't see anything. Searches on Google and these forums also come up blank.

    Is it really the case that writing to a text file in VB6 in a MapPoint addin is unreliable?

    I guess a workaround would be write a C++ COM program that did the file writing and call this in a similar way as Excel.

    Or I could just drop the text file output options from this add-in...

    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: Writing files in a VB Addin?

    Hi Richard,

    I did never write an add-in. But it's just a DLL called yes ? Maybe you can try to see if you have same problem if called from another program you write. Also then you can step trought te code.

    Hope this make sence because so sayd I never wrote an add in...

    It sound very strange to me there should be something wrong with writing to disk. What is the error you get ? Can you trap it ?

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

    Re: Writing files in a VB Addin?

    I get the standard XP "MapPoint has a problem" error with options to pass to the info to Microsoft.

    I tried running it in the debugger, but then it works of course!


    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  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

    Re: Writing files in a VB Addin?

    It looks like the route finding is important.

    Ie. writing files & route finding.
    Disable the route finding, and it runs okay.

    I'd already tried "open,write,close" in one short sequence rather than keeping the file(s) open for a long period, so it isn't the fact that the file is open when a route is calculated.

    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  5. #5
    Paul Larson is offline Senior Member Green Belt
    Join Date
    Sep 2005
    Location
    Battle Creek, Michigan
    Posts
    136

    Smile Re: Writing files in a VB Addin?

    Sounds like it could well be a filehandle allocation problem.
    A lot of old COM code used constants when allocating filehandles. You might try assigning filehandles using freefile() and then adding 100 or something similar.

    HTH
    Paul

  6. #6
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: Writing files in a VB Addin?

    Richard, are you sure it has nothing to do with a global variable ? Do you have all local (stack) ? I have no idea, but just write what comes trough my one braincell

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

    Re: Writing files in a VB Addin?

    I've been using freefile.
    Freefile+100? I could try it.

    If this worked, it would mean that MapPoint (running under XP only) has hard-coded file handle?

    A potential customer has a log from MapPoint, and it looks like an internal buffer overflow. Really strange!

    Wilfried: I know you're guessing, but I've had similar thoughts elsewhere. This is VB6 so there are a lot of globals (VB6's concept of object oriented programming is not qute 'fully formed'). However I've been converting them to Private (yes I was sloppy with lots of public vars). No luck so far.


    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

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

    Re: Writing files in a VB Addin?

    Just an update before I forget (again!) - the Freefile+100 didn't work.
    I'm pulling the text file functionality out...

    I don't like doing this, but to make up, I'm also adding support for Excel 2007's extra-large spreadsheets.

    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. HOW TO: MP addin using .NET
    By Labtek in forum MapPoint Desktop Discussion
    Replies: 10
    Last Post: 12-14-2004, 02:37 PM
  2. C# AddIn
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 12-20-2003, 07:44 PM
  3. Writing a new COM component for MapPoint2002
    By tanguy_laverdure in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 12-04-2003, 03:03 AM
  4. COM AddIn in C++/ATL
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 10-22-2003, 10:41 AM
  5. "Microsoft Mappoint" writing and Pushpin Highligth
    By feanor in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 03-12-2003, 05:47 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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96