Need Help VB App Speed and Findresult Error

pcigreg
04-14-2007, 07:03 PM
I am creating a VB application that searches for matches of Office locations to a user suplied address -objLOC(1) . I am looping through an access db and Pushpining the office Locations. There are roughly 100 locations and maybe 30 meet the 25 mile critera, but it takes around 30 seconds to do this. Is this normal?

Also if the address is bad, like say a PO Box instead of a street address, it bombs out with a " MEthod Find Address Results of Object_Map Failed " error, shouldn't it just find it with a bad result quality?

Here is the code

Do Until rsA.EOF

Set objFIND = Me.MappointControl1.ActiveMap.FindAddressResults
(rsA! aglocstradr, rsA!agloccity, , rsA!agloczip)
If objFIND.ResultsQuality <> geoFirstResultGood Then GoTo Nextone
Set objLoc(x) = objFIND.Item(1)
If objLoc(1).DistanceTo(objLoc(x)) > 25 Then GoTo Nextone
Set objPIN(x) = MappointControl1.ActiveMap.AddPushpin(objLoc(x), rsA!agname)
objPIN(x).Symbol = 25
x = x + 1

Nextone:

rsA.MoveNext
Loop

Wilfried
04-17-2007, 05:58 AM
Hi,

Please set next time your code between [ code] [ /code] tags for better readability.

You should do a few additional checks. First of all you should sheck if the item is a Location object (because it also can be a Pushpin object). Then if it is a Location object. Then you can see if it is a valid address by checking the StreetAddress property. It can be null (I think Nothing in VB). But you can also check the Type property for this (Look for GeoShowDataBy in the help), but checking StreetAddress should be ok also.

About speed, try to figure out whitch line of code take the most time to see what we can speedup. If the DistanceTo take time then you can write this yourself, and if it is the adding of pushpins then you can use a file to add them all at once. But I think it is the FindAddressResults that take the most time. There is a windows API call GetTickCount that you can use to measure the time (milliseconds, but is sufficient in this case).

Paul Larson
04-17-2007, 02:05 PM
You should create a base pushpin map with all your office locations as pushpins (instead of forcing mappoint to geocode the offices each time you do a search.)

When performing the search, geocode the starting (customer) address, and create a radius around it. Then use the QueryCircle() method to find all office locations within a 25 mile radius.

HTH
Paul

 
Web mp2kmag.com
mapforums.com