Discussion:
Array in Mappoint Shape
(too old to reply)
Bill Nguyen
2007-01-29 22:57:34 UTC
Permalink
I tried to use theis example from MSDN but got error in "Array"

arrTri = Array(locFL, locPR, locB, locFL)

Can someone please tell me how to get it run in VB.NET?

Thanks

Bill

Public Shared Sub BermudaTriangle()

Dim oMap As MapPoint.Map

oMap = GetObject(, "MapPoint.Application").ActiveMap

Dim locFL, locPR, locB As MapPoint.Location

locFL = oMap.FindResults("Fort Lauderdale, Florida")(1)

locPR = oMap.FindResults("San Juan, Puerto Rico")(1)

locB = oMap.FindResults("Bermuda")(1)

Dim arrTri

arrTri = Array(locFL, locPR, locB, locFL)

' Go there first

oMap.Union(arrTri).GoTo()

' Create and name the shape

oMap.Shapes.AddPolyline(arrTri).Name = "Bermuda Triangle"

End Sub
unknown
2007-01-29 23:14:01 UTC
Permalink
Post by Bill Nguyen
I tried to use theis example from MSDN but got error in "Array"
arrTri = Array(locFL, locPR, locB, locFL)
Can someone please tell me how to get it run in VB.NET?
Thanks
Bill
Public Shared Sub BermudaTriangle()
Dim oMap As MapPoint.Map
oMap = GetObject(, "MapPoint.Application").ActiveMap
Dim locFL, locPR, locB As MapPoint.Location
locFL = oMap.FindResults("Fort Lauderdale, Florida")(1)
locPR = oMap.FindResults("San Juan, Puerto Rico")(1)
locB = oMap.FindResults("Bermuda")(1)
Dim arrTri
arrTri = Array(locFL, locPR, locB, locFL)
' Go there first
oMap.Union(arrTri).GoTo()
' Create and name the shape
oMap.Shapes.AddPolyline(arrTri).Name = "Bermuda Triangle"
End Sub
Declare your array variable with parens post-pended, as in
Dim MyLocations(3) as MapPoint.Location
where "3" is the upper (zero-based) index boundary.

A re-code of your example would be
'-----------------------------------------
Public Shared Sub BermudaTriangle()

Dim oMap As MapPoint.Map

oMap = GetObject(, "MapPoint.Application").ActiveMap

Dim arrLocTri(2) As MapPoint.Location

arrLocTri(0) = oMap.FindResults("Fort Lauderdale, Florida")(1)

arrLocTri(1) = oMap.FindResults("San Juan, Puerto Rico")(1)

arrLocTri(2) = oMap.FindResults("Bermuda")(1)

oMap.Union(arrLocTri).GoTo()

oMap.Shapes.AddPolyline(arrLocTri).Name = "Bermuda Triangle"

End Sub

'-----------------------------------------

Also, note that your code does not create a "closed" triangle. If you wish
to close it, you'll need to add location(0) as item(3) to the array, as in
Dim arrLocaTri(3) as MapPoint.Location
...
arrLocTri(3)=arrLocTri(0)


HTH
Paul

Continue reading on narkive:
Search results for 'Array in Mappoint Shape' (Questions and Answers)
3
replies
Required Java syllabus?
started 2007-07-25 22:08:10 UTC
programming & design
Loading...