Home All Groups Group Topic Archive Search About
Author
14 Dec 2006 5:04 PM
Marc
Anyone know why the below array doesnt work?


Dim locations() As MapPoint.Location
    Set locations(1) = objMap.FindResults("Los Angeles, California")(1)
    Set locations(2) = objMap.FindResults("Honolulu, Hawaii")(1)
    Set locations(3) = objMap.FindResults("Tokyo, Japan")(1)


Dim oShp As MapPoint.Shape
    Set oShp = objMap.Shapes.AddPolyline(locations)

Author
14 Dec 2006 5:24 PM
Robinson
Try:


Dim locations(2) As MapPoint.Location

or.....

Dim locations as New List(Of MapPoint.Location)

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


Show quoteHide quote
"Marc" <marc_cro***@hotmail.com> wrote in message
news:1166115879.575937.193870@79g2000cws.googlegroups.com...
>  Anyone know why the below array doesnt work?
>
>
> Dim locations() As MapPoint.Location
>    Set locations(1) = objMap.FindResults("Los Angeles, California")(1)
>    Set locations(2) = objMap.FindResults("Honolulu, Hawaii")(1)
>    Set locations(3) = objMap.FindResults("Tokyo, Japan")(1)
>
>
> Dim oShp As MapPoint.Shape
>    Set oShp = objMap.Shapes.AddPolyline(locations)
>
Author
14 Dec 2006 6:44 PM
Andrew Backer
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.Collections.Generic.List(Of MapPoint.Location)(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:
Show quoteHide quote
> Try:
>
>
> Dim locations(2) As MapPoint.Location
>
> or.....
>
> Dim locations as New List(Of MapPoint.Location)
>
> locations.Add (obj.Map............ etc.)
>
>
> "Marc" <marc_cro***@hotmail.com> wrote in message
> news:1166115879.575937.193870@79g2000cws.googlegroups.com...
> >  Anyone know why the below array doesnt work?
> >
> >
> > Dim locations() As MapPoint.Location
> >    Set locations(1) = objMap.FindResults("Los Angeles, California")(1)
> >    Set locations(2) = objMap.FindResults("Honolulu, Hawaii")(1)
> >    Set locations(3) = objMap.FindResults("Tokyo, Japan")(1)
> >
> >
> > Dim oShp As MapPoint.Shape
> >    Set oShp = objMap.Shapes.AddPolyline(locations)
> >
Author
15 Dec 2006 12:04 AM
Herfried K. Wagner [MVP]
"Marc" <marc_cro***@hotmail.com> schrieb:
>  Anyone know why the below array doesnt work?
>
> Dim locations() As MapPoint.Location
>    Set locations(1) = objMap.FindResults("Los Angeles, California")(1)
>    Set locations(2) = objMap.FindResults("Honolulu, Hawaii")(1)
>    Set locations(3) = objMap.FindResults("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.public.vb.*" hierarchy.

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

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

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/>