Hi,
I'm developing an application with visual basic and mappoint 2002 Europe, and I have a problem with a try.
I have a form with a Mappoint Control on it, a listview, a textbox (in order to indicate the place to find), and two command buttons.
When clicking the first command button, I search for the place on the textbox and put the results in the listview. Then, I select one of the results on the listview and click the second command button in order to go to that location.
The problem arises when I try to go to a location previously shown. Then, I'm shown the error 13 in runtime.
Do you know what the problem is?
Here is the code:
Option Explicit
Dim oMap As MapPoint.Map
Private Sub buscar_Click()
ListView1.ListItems.Clear
Mostrar
End Sub
Private Sub Command1_Click()
Dim oLoc As MapPoint.Location
MsgBox ListView1.SelectedItem.Text
Dim oPin As MapPoint.Pushpin
Set oLoc = oMap.FindResults(ListView1.SelectedItem.Text)(1) 'Here is when the error message is shown.
oLoc.GoTo
Set oPin = oMap.AddPushpin(oLoc)
oPin.BalloonState = geoDisplayBalloon
oPin.BalloonState = geoDisplayName
oPin.BalloonState = geoDisplayNone
oPin.Symbol = 133
oPin.Highlight = True
Set oLoc = Nothing
'If I comment the lines with oPin, it works, but I need the Pushpin.
'If I comment Set oLoc=Nothing, it fails again.
End Sub
Private Sub Form_Load()
MappointControl1.NewMap geoMapEurope
ListView1.View = lvwReport
ListView1.FullRowSelect = True
ListView1.GridLines = True
ListView1.HideSelection = False
ListView1.ColumnHeaders.Clear
ListView1.ColumnHeaders.Add , , "Place", ListView1.Width
End Sub
Private Sub Form_Unload(Cancel As Integer)
MappointControl1.ActiveMap.Saved = True
End Sub
Sub Mostrar()
Dim oFound As MapPoint.FindResults
Set oMap = GetObject(, "MapPoint.Application").ActiveMap
Set oFound = oMap.FindPlaceResults(Text1.Text)
If (oFound.Count > 0) Then
Dim i As Integer
i = 1
For i = 1 To oFound.Count
ListView1.ListItems.Add , , oFound.Item(i).Name
Next
End If
End Sub
Thanks a lot...