I'm experiencing problems when using the MS Mappoint ActiveX FindNearby
command in a loop. My program places 50 pushpins
on a map. Then I load +/- 5000 points (lat,lon) one by one to
check if they are close to one of these pushpins. When I
run this form once it works fine but when running it for
the +/- 4th time the application (mappoint.exe ActiveX control)hangs. If I click the pause (break all button) it hangs at the following line.

For Each oObj In oRes

When I have a look at the Local Values i see that most of the responses are “error: cannot obtain value”

Can someone please help me with this problem? As
you can see I copied a part of the code below

Thanks in advance,



main program:

Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
Dim frm_zoeken as new Form_Zoeken
End Sub

called program:

Private oRes As MapPoint.FindResults

private sub DatabaseLoop
"load latitude and logitude from database"

End Sub

Private Sub NearbyLocation()
Dim oObj As Object
Dim oLoc As MapPoint.Location
Dim oPin As MapPoint.Pushpin
Dim oRes_teller As Integer = 0

locatie_STR = ""

'Loop over collection
For Each oObj In oRes
Dim sTxt As String

'Find out object type
If TypeOf oObj Is MapPoint.Pushpin Then
oPin = oObj
locatie_STR = oPin.Name
Exit For
End If
Next oObj
End Sub