Select to view content in your preferred language

General error executing calculator

3610
10
11-02-2010 05:19 PM
JamesWhisenhunt
Deactivated User
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
0 Kudos
10 Replies
F_Pfaefflin
Emerging Contributor
Through (re-)reporting the Bug to my local support, the severity of NIM-061356 at least moved to "High". One problem seems to have been that the bug report implies that the issue affects only VBA (which is deprecated). But in fact it affects all ArcObjects .NET developments.  Let's hope for a quick fix ...
Florian.
0 Kudos