<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Field calculator code snippet doesn't work now that ArcMap 10 doesn't support VBA in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/field-calculator-code-snippet-doesn-t-work-now/m-p/171039#M5743</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Did you check Ianko's website &lt;A href="http://www.ian-ko.com/"&gt;http://www.ian-ko.com/&lt;/A&gt;&lt;BR /&gt;to see if he has provided updates for version 10? I did and there is stuff there. You should bookmark the site and visit it regularly to keep current with the new tools provided for ArcMap &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;He did not update all the easy calculate functions-in particular he did not update cumulate values- only the edit, geometry and a few other functions.&amp;nbsp; Where he did update, it was in a way that cannot be used with modelbuilder; he made a button using .Net.&amp;nbsp; In his latest update, he said he was not going to update for 10 and recommended using .net to do everything because VBA was on its way out.&amp;nbsp; What does everyone think?&amp;nbsp; Is there a quick fix to make this code work with Vbscript so the field calculator can be used or should I use .Net.&amp;nbsp; And if I use .Net will it be an easy transition?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Blair&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 11 Jan 2011 22:10:56 GMT</pubDate>
    <dc:creator>blairborries</dc:creator>
    <dc:date>2011-01-11T22:10:56Z</dc:date>
    <item>
      <title>Field calculator code snippet doesn't work now that ArcMap 10 doesn't support VBA</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-calculator-code-snippet-doesn-t-work-now/m-p/171037#M5741</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a very large automation model created in modelbuilder that I've been using for a couple of years now and with the upgrade to 10, it no longer works because it contains code snippets in which a static variable is declared at the beginning of the code.&amp;nbsp; The part that gets an error contains a part of the cumulate values code that is included in Easy Calculate.&amp;nbsp; This part of my model sums up the values in each row of a column according to the values in an adjacent column. ie.:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[Sourcefield] [Targetfield]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 15&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Obvious, I'm sure to anyone familiar with VBA and Vbscript is that Vbscript does not accept static variables declared at the onset of a set of code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code is simple, I've copied it below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;'=========================&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'field_CumulateValues.cal&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'Author: Ianko Tchoukanski&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://www.ian-ko.com" rel="nofollow" target="_blank"&gt;http://www.ian-ko.com&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'=========================&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Static rec As Long&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Static dSum As Double&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim sourceField&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'=================&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'adjust the source field name below&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;sourceField = &lt;A&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'=================&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If (rec = 0) Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; dSum = sourceField&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Else&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; dSum = sourceField + dSum&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;End If&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rec = rec + 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;__esri_field_calculator_splitter__&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;dSum&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't know a whole lot about VBA or Vbscript, I've just picked up a little through editing code snippets to meet my needs.&amp;nbsp; So, I'm wondering if anyone knows a quick fix for this to make it work with Vbscript, someway to remove the static declaration, or if not if you can give some advice... I need to make this code work so I'll learn what I need to figure this out.&amp;nbsp; Will it be easiest/best to make modelbuilder model into .net code (there's not much more complicated to it than this cumulate values code) and compile into a button or try to rewrite the cumulate values code as a vbscript snippet without using the static declarative?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Blair&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Jan 2011 21:41:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-calculator-code-snippet-doesn-t-work-now/m-p/171037#M5741</guid>
      <dc:creator>blairborries</dc:creator>
      <dc:date>2011-01-11T21:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculator code snippet doesn't work now that ArcMap 10 doesn't support VBA</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-calculator-code-snippet-doesn-t-work-now/m-p/171038#M5742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Did you check Ianko's website &lt;/SPAN&gt;&lt;A href="http://www.ian-ko.com/"&gt;http://www.ian-ko.com/&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;to see if he has provided updates for version 10?&amp;nbsp; I did and there is stuff there.&amp;nbsp; You should bookmark the site and visit it regularly to keep current with the new tools provided for ArcMap&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Jan 2011 22:02:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-calculator-code-snippet-doesn-t-work-now/m-p/171038#M5742</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2011-01-11T22:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculator code snippet doesn't work now that ArcMap 10 doesn't support VBA</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-calculator-code-snippet-doesn-t-work-now/m-p/171039#M5743</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Did you check Ianko's website &lt;A href="http://www.ian-ko.com/"&gt;http://www.ian-ko.com/&lt;/A&gt;&lt;BR /&gt;to see if he has provided updates for version 10? I did and there is stuff there. You should bookmark the site and visit it regularly to keep current with the new tools provided for ArcMap &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;He did not update all the easy calculate functions-in particular he did not update cumulate values- only the edit, geometry and a few other functions.&amp;nbsp; Where he did update, it was in a way that cannot be used with modelbuilder; he made a button using .Net.&amp;nbsp; In his latest update, he said he was not going to update for 10 and recommended using .net to do everything because VBA was on its way out.&amp;nbsp; What does everyone think?&amp;nbsp; Is there a quick fix to make this code work with Vbscript so the field calculator can be used or should I use .Net.&amp;nbsp; And if I use .Net will it be an easy transition?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Blair&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Jan 2011 22:10:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-calculator-code-snippet-doesn-t-work-now/m-p/171039#M5743</guid>
      <dc:creator>blairborries</dc:creator>
      <dc:date>2011-01-11T22:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculator code snippet doesn't work now that ArcMap 10 doesn't support VBA</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-calculator-code-snippet-doesn-t-work-now/m-p/171040#M5744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well, I think I've found my own answer.&amp;nbsp; For anyone else trying to solve the same problem, it looks like ESRI has put up some instructions on how to do "accumulative functions" with python inside the code block.&amp;nbsp; This may be the quick fix i was looking for, but I still haven't tested it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//005s0000002m000000.htm"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//005s0000002m000000.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Parser:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Python&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;accumulate(!FieldA!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code Block:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;total = 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;def accumulate(increment):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; global total&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if total:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; total += increment&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; total = increment&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; return total&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Jan 2011 22:36:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-calculator-code-snippet-doesn-t-work-now/m-p/171040#M5744</guid>
      <dc:creator>blairborries</dc:creator>
      <dc:date>2011-01-11T22:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculator code snippet doesn't work now that ArcMap 10 doesn't support VBA</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-calculator-code-snippet-doesn-t-work-now/m-p/171041#M5745</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;stick with Python solutions, VBA is gone, perhaps VBScript will be next, Python is stable for the next three years (aka no major changes, just bug fixes) and it seems to be the preferred scripting/programming environment within Arcmap and open source GIS packages.&amp;nbsp; Pretty anything you see in VBA can be converted to Python easily (start by removing the Dim this, Dim that stuff), the only thing that isn't great is the code block section within the field calculator which eventually will allow one to load Python scripts like the old VB scripts....translate away&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Jan 2011 23:06:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-calculator-code-snippet-doesn-t-work-now/m-p/171041#M5745</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2011-01-11T23:06:08Z</dc:date>
    </item>
  </channel>
</rss>

