IArray cannot be indexed because it has no default property

727
1
04-23-2010 03:46 AM
DawnBlanchard
New Contributor
I pulled a piece of code from a user forum to use the geoprocessing AnalysisTools.Intersect but I am still having some trouble.

Here's the code that is giving me trouble:

Dim infcs As IArray

            'infcs = New ESRI.ArcGIS.esriSystem.Array
            infcs = New ESRI.ArcGIS.esriSystem.Array

            infcs = infcsFeat()

            'infcs() is an array of feature classes that I want to intersect
            'the geoprocessing tool expects a semicolon delimited list of paths
            For i = 0 To UBound(infcs) - 2
                pDataset = infcs(i)
                pWorkspace = pDataset.Workspace
                fcnames = fcnames & "'" & pWorkspace.PathName & "\" & pDataset.Name & ".shp'" & ";"


            Next
            pDataset = infcs(UBound(infcs) - 1)
            pWorkspace = pDataset.Workspace
            fcnames = fcnames & "'" & pWorkspace.PathName & "\" & pDataset.Name & ".shp'"


infcs is an IArray that is being populated with the workspaces needed for the intersection.  The errors that is occurring is in the For statement and right after the for statement on the infcs.  The error is: "Interface 'ESRI.ArcGIS.esriSystem.IArray' cannot be indexed because it has no default property".

Does anyone know how I can fix this error?

Thanks,

Dawn
0 Kudos
1 Reply
JamesMacKay
New Contributor
Hey Dawn,

Rather than using an indexer directly on the infcs variable, use the Element property, i.e.:

Dim val as Object = infcs.Element(i)


Cheers,
James
0 Kudos