In the application I am writing, I take a list of addresses from a customer database. I pass that list to MapPoint and optimize the route. Then, I need to read the individual addresses out of Mappoint so that I can write the addresses back to a text file in their new optimized order. With me so far?
So, here's my code that builds the route:
and here's my export code.Code:For intStopCounter = 0 To lstStops.ListCount - 1 oRte.Waypoints.Add oMap.FindAddressResults(stopData(intStopCounter).add1, _ stopData(intStopCounter).city, , _ stopData(intStopCounter).state, _ stopData(intStopCounter).zip)(1) Next
I'm getting an error on the second line of the export, the line that tries to get the StreetAddress.Street value. The error I'm seeing is "The requested member of the collection does not exist. Use a valid name or index number."Code:intFileNumber = FreeFile Open strFileName For Output As intFileNumber For intStopCounter = 0 To oRte.Waypoints.Count - 1 strOut = Trim(Str(intStopCounter)) & "|" strOut = oRte.Waypoints.Item(intStopCounter).Location.StreetAddress.Street & "|" strOut = oRte.Waypoints.Item(intStopCounter).Location.StreetAddress.city & "|" strOut = oRte.Waypoints.Item(intStopCounter).Location.StreetAddress.Region & "|" strOut = oRte.Waypoints.Item(intStopCounter).Location.StreetAddress.PostalCode & "|" strOut = Trim(Str(oRte.Waypoints.Item(intStopCounter).ListPosition)) Print #intFileNumber, strOut Next Close intFileNumber
Can someone tell me where I'm going wrong? Thanks in advance. I can't seem to figure out precisely what's wrong.