Array help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marc

    #1

    Array help

    Anyone know why the below array doesnt work?


    Dim locations() As MapPoint.Locati on
    Set locations(1) = objMap.FindResu lts("Los Angeles, California")(1)
    Set locations(2) = objMap.FindResu lts("Honolulu, Hawaii")(1)
    Set locations(3) = objMap.FindResu lts("Tokyo, Japan")(1)


    Dim oShp As MapPoint.Shape
    Set oShp = objMap.Shapes.A ddPolyline(loca tions)

  • Robinson

    #2
    Re: Array help

    Try:


    Dim locations(2) As MapPoint.Locati on

    or.....

    Dim locations as New List(Of MapPoint.Locati on)

    locations.Add (obj.Map....... ..... etc.)


    "Marc" <marc_crosby@ho tmail.comwrote in message
    news:1166115879 .575937.193870@ 79g2000cws.goog legroups.com...
    Anyone know why the below array doesnt work?
    >
    >
    Dim locations() As MapPoint.Locati on
    Set locations(1) = objMap.FindResu lts("Los Angeles, California")(1)
    Set locations(2) = objMap.FindResu lts("Honolulu, Hawaii")(1)
    Set locations(3) = objMap.FindResu lts("Tokyo, Japan")(1)
    >
    >
    Dim oShp As MapPoint.Shape
    Set oShp = objMap.Shapes.A ddPolyline(loca tions)
    >

    Comment

    • Andrew Backer

      #3
      Re: Array help

      It does not work because you have not actually allocated an array, just
      declared that this variable is of type "array of location".

      As the previous poster said, either declare the array size before hand,
      or use a list of objects that is of the same type. You might end up
      with

      System.Collecti ons.Generic.Lis t(Of MapPoint.Locati on)(3)

      where 3 is the initial size you want (you can shorten that declaration
      up, for sure!)

      After that you can just call the .ToArray() function get the an array
      of those objects out, if that is what your function requires.

      // Andrew

      Robinson wrote:
      Try:
      >
      >
      Dim locations(2) As MapPoint.Locati on
      >
      or.....
      >
      Dim locations as New List(Of MapPoint.Locati on)
      >
      locations.Add (obj.Map....... ..... etc.)
      >
      >
      "Marc" <marc_crosby@ho tmail.comwrote in message
      news:1166115879 .575937.193870@ 79g2000cws.goog legroups.com...
      Anyone know why the below array doesnt work?


      Dim locations() As MapPoint.Locati on
      Set locations(1) = objMap.FindResu lts("Los Angeles, California")(1)
      Set locations(2) = objMap.FindResu lts("Honolulu, Hawaii")(1)
      Set locations(3) = objMap.FindResu lts("Tokyo, Japan")(1)


      Dim oShp As MapPoint.Shape
      Set oShp = objMap.Shapes.A ddPolyline(loca tions)

      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: Array help

        "Marc" <marc_crosby@ho tmail.comschrie b:
        Anyone know why the below array doesnt work?
        >
        Dim locations() As MapPoint.Locati on
        Set locations(1) = objMap.FindResu lts("Los Angeles, California")(1)
        Set locations(2) = objMap.FindResu lts("Honolulu, Hawaii")(1)
        Set locations(3) = objMap.FindResu lts("Tokyo, Japan")(1)
        Your code looks like VB6 code. If your question is related to VB6, consider
        posting it in one of the groups in the "microsoft.publ ic.vb.*" hierarchy.

        BTW: You need to dimension the array prior to using it:

        \\\
        Dim Locations(0 To n) As MapPoint.Locati on
        ///

        In VB.NET, 'Set' is not required.

        --
        M S Herfried K. Wagner
        M V P <URL:http://dotnet.mvps.org/>
        V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

        Comment

        Working...