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

Programming in VB.Net

This is a discussion on Programming in VB.Net within the MapPoint Desktop Discussion forums, part of the Map Forums category; I'm just starting with VB.Net and MapPoint 2004. The code on MSDN doesn't seem to work for me though! I ...

  1. #1
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    Programming in VB.Net

    I'm just starting with VB.Net and MapPoint 2004. The code on MSDN doesn't seem to work for me though! I suspect it's differences between VB6/VB.Net and also MapPoint2002/2004.

    I'm trying to give a location in Lat/Lon, and return a list of attributes at that location. I can get a map, and place pushpins ok, but the next part is causing an error. The code I have so far (to find 1 location) is:
    Code:
    'Get a location on the map
    oloc = omap.FindResults("51.577141, 0.291178").Item(1)
    
    'Find nearby places 0.5 miles from that location
    MsgBox("Closest place: " + oloc.FindNearby(0.5).Item(1).Name)
    The error is: 'The requested member of the collection does not exist. Use a valid name or index number.'

    The above code came straight off MSDN. Can anyone help with this problem, or expand the code to produce a full list of attributes at that location?

    Thanks

    Nick

  2. #2
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478
    You need to use the "GetLocation method" insted of "FindResults Method"

  3. #3
    NickS's Avatar
    NickS is offline Junior Member White Belt
    Join Date
    Nov 2003
    Posts
    10
    Can you be more specific? The MSDN help for FindLocation is ok - but the MSDN FindNearby help gives the code that I've already got (Using FindResults)!

    Thanks

    Nick

  4. #4
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478
    The reason you got the error (The requested member of the collection does not exist. Use a valid name or index number) is because there was not anything nearby. Try this example. Put this code in a command button and see if it works better. It should find Pushpin1.

    Code:
    Try
      Dim omap As MapPoint.Map
      omap = AxMappointControl1.ActiveMap
      Dim oloc As MapPoint.Location
      Dim opin As MapPoint.Pushpin
    
      oloc = omap.GetLocation(51.577141, 0.291178, 250)
      opin = omap.AddPushpin(oloc, "Pushpin1")
      opin.BalloonState = MapPoint.GeoBalloonState.geoDisplayBalloon
      opin.Location.GoTo()
    
      'Find nearby places 0.5 miles from that location 
       MsgBox("Closest place: " + oloc.FindNearby(0.5).Item(1).Name)
    
    Catch ex As Exception
      MessageBox.Show(ex.Message)
    End Try

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Programming using excel VBA... No GPS
    By KUSteveo in forum MapPoint Desktop Discussion
    Replies: 5
    Last Post: 09-20-2008, 02:33 PM
  2. Ambiguous messages ( programming or not programming? )
    By Mohamed in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 06-13-2006, 04:35 PM
  3. Programming MapPoint via .NET
    By Anonymous in forum MP2K Magazine Articles
    Replies: 1
    Last Post: 02-21-2006, 10:42 AM
  4. How to programming using VC6.0
    By confach in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 03-01-2004, 06:25 AM
  5. In using MapPoint in programming with VB how do yo....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 11-27-2001, 02:53 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