title: How do I use ICalculator in ArcEngine?
body: <p>I'm trying to calculate value for field from the attribute table of a shapefile using ArcEngine, looking up in EDN &amp; ArcGIS help and I wrote code as below:</p>
  
  <pre><code>ICalculator pCalculator = new Calculator();
  pCalculator.Field = pField.Name;
  string ex = "!POP06!-!POP02!";
  pCalculator.Expression = ex;
  pCalculator.Calculate();
  </code></pre>
  
  <p><code>pField</code> is the target field I want to update the value, <code>POP06</code> &amp; <code>POP02</code> are two fields I use to calculate, using <code>!</code> for python.</p>
  
  <p>When I run the program VS2010 said "Error HRESULT E_FAIL has been returned from a call to a COM component". I could tell that ICalcultor haven't set any dependence on attribute table, but I don't know how to do. Also, are there any other problems in my code?</p>