Hello all,
I am trying to update the area field on a shapefile; however, I am getting the following error:
"Error HRESULT_FAIL has returned from a call to a COM component"
This was originally written in 9.3.1 and worked without problems. Any ideas why I am having problems in ArcMap 10?
As always thanks for all help,
James
Private Sub UpdateArea(ByVal pFlayer As IFeatureLayer)
[INDENT]
Try
[INDENT]Dim pfClass As IFeatureClass
pfClass = pFlayer.FeatureClass
Dim pCalc As ICalculator
pCalc = New Calculator
Dim pCursor As ICursor
pCursor = pfClass.Update(Nothing, True)
With pCalc
[INDENT].Cursor = pCursor
.PreExpression = "Dim dblArea as double" & vbNewLine & _
[INDENT][INDENT][INDENT]"Dim pArea As IArea" & vbNewLine & _
"Set pArea = [Shape]" & vbNewLine & _
"dblArea = pArea.Area"[/INDENT][/INDENT][/INDENT]
.Expression = "dblArea"
.Field = "Area"[/INDENT]
End With
pCalc.Calculate()
pCursor = Nothing
[/INDENT]
Catch ex As Exception
[INDENT]MsgBox(ex.Message.ToString)[/INDENT]
End Try
[/INDENT]
End Sub