<?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: Calculate Field Code Block VB Help in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/calculate-field-code-block-vb-help/m-p/498576#M28308</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Excellent Chris, this works perfectly. Thanks very much.&lt;BR /&gt;&lt;BR /&gt;DK&lt;BR /&gt;&lt;BR /&gt;P.S. Any idea why &lt;SPAN style="font-style:italic;"&gt;elseif&lt;/SPAN&gt; is one work but &lt;SPAN style="font-style:italic;"&gt;end if&lt;/SPAN&gt; is two?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am not sure, but this is consistent with all VB languages.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/752y8abs(v=vs.80).aspx"&gt;http://msdn.microsoft.com/en-us/library/752y8abs(v=vs.80).aspx&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 13 Mar 2013 15:12:34 GMT</pubDate>
    <dc:creator>ChrisFox3</dc:creator>
    <dc:date>2013-03-13T15:12:34Z</dc:date>
    <item>
      <title>Calculate Field Code Block VB Help</title>
      <link>https://community.esri.com/t5/data-management-questions/calculate-field-code-block-vb-help/m-p/498567#M28299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi folks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have an empty field that I want to populate with text dependent on the value of another field. In Excel this would be a breeze but I'm having trouble with the syntax and the code block structure of the Calculate Field tool. I'm using the tool in VB mode and below is what I have currently got, resulting in the very helpful 99999 Error Code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In Expression dialogue box:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;temp&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In Code Block:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;DIM temp as String IF OBJECTID='1' THEN temp = 'Very Destructive' ELSEIF OBJECTID='2' THEN temp = 'Destructive' ELSEIF OBJECTID='3' THEN temp = 'Damaging' ENDIF &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is resulting in errors as described above; 'Expecting end of statement'. I'm fairly certain this is a syntax issue but if it is more complicated then please advise. any assistance would be greatly appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DK&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Mar 2013 01:02:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/calculate-field-code-block-vb-help/m-p/498567#M28299</guid>
      <dc:creator>DarrochKaye</dc:creator>
      <dc:date>2013-03-11T01:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field Code Block VB Help</title>
      <link>https://community.esri.com/t5/data-management-questions/calculate-field-code-block-vb-help/m-p/498568#M28300</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Darroch,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Field names need to be placed in brackets:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;DIM temp as String&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IF [OBJECTID]='1' THEN temp = 'Very Destructive'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [OBJECTID]='2' THEN temp = 'Destructive'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [OBJECTID]='3' THEN temp = 'Damaging'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ENDIF&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anthony&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Mar 2013 05:59:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/calculate-field-code-block-vb-help/m-p/498568#M28300</guid>
      <dc:creator>AnthonyGiles</dc:creator>
      <dc:date>2013-03-11T05:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field Code Block VB Help</title>
      <link>https://community.esri.com/t5/data-management-questions/calculate-field-code-block-vb-help/m-p/498569#M28301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; Darroch,&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;Field names need to be placed in brackets:&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;DIM temp as String&amp;nbsp; &lt;BR /&gt;IF [OBJECTID]='1' THEN temp = 'Very Destructive'&amp;nbsp; &lt;BR /&gt;ELSEIF [OBJECTID]='2' THEN temp = 'Destructive'&amp;nbsp; &lt;BR /&gt;ELSEIF [OBJECTID]='3' THEN temp = 'Damaging'&amp;nbsp; &lt;BR /&gt;ENDIF&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;Regards&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;Anthony&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the info but I'm still getting the same error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color:&amp;quot;#008000&amp;quot;;"&gt;General error executing calculator.&lt;/SPAN&gt;
&lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;ERROR 999999: Error executing function.
Expected end of statement
Failed to execute (CalculateField).&lt;/SPAN&gt;&lt;/PRE&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DK&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:54:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/calculate-field-code-block-vb-help/m-p/498569#M28301</guid>
      <dc:creator>DarrochKaye</dc:creator>
      <dc:date>2021-12-11T21:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field Code Block VB Help</title>
      <link>https://community.esri.com/t5/data-management-questions/calculate-field-code-block-vb-help/m-p/498570#M28302</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try using double speech marks around your text, and a space between your end and if on your last line, also the last else if only needs to be an else statement, plus the objectid field is numeric so you don't need the values in speech marks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;DIM temp as String&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IF [OBJECTID] = 1 THEN temp = "Very Destructive"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [OBJECTID] = 2 THEN temp = "Destructive"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSE [OBJECTID] = 3 THEN temp = "Damaging"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;END IF&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Mar 2013 22:04:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/calculate-field-code-block-vb-help/m-p/498570#M28302</guid>
      <dc:creator>AnthonyGiles</dc:creator>
      <dc:date>2013-03-11T22:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field Code Block VB Help</title>
      <link>https://community.esri.com/t5/data-management-questions/calculate-field-code-block-vb-help/m-p/498571#M28303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Try using double speech marks around your text, and a space between your end and if on your last line, also the last else if only needs to be an else statement, plus the objectid field is numeric so you don't need the values in speech marks.&lt;BR /&gt;&lt;BR /&gt;DIM temp as String&lt;BR /&gt;IF [OBJECTID] = 1 THEN temp = "Very Destructive"&lt;BR /&gt;ELSEIF [OBJECTID] = 2 THEN temp = "Destructive"&lt;BR /&gt;ELSE [OBJECTID] = 3 THEN temp = "Damaging"&lt;BR /&gt;END IF&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I had tried various double quote and single quote methods but still receiving the same error. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;N.B. This doesn't have to be written in VB; if anyone knows how to write this in Python then please comment.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DK&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Mar 2013 22:24:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/calculate-field-code-block-vb-help/m-p/498571#M28303</guid>
      <dc:creator>DarrochKaye</dc:creator>
      <dc:date>2013-03-11T22:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field Code Block VB Help</title>
      <link>https://community.esri.com/t5/data-management-questions/calculate-field-code-block-vb-help/m-p/498572#M28304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Darrock,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Did you also make the other changes I suggested not just the quotes?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anthony&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;P.S. not sure what version of arcmap your are using but I have just found this article:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://support.esri.com/en/knowledgebase/techarticles/detail/25207"&gt;http://support.esri.com/en/knowledgebase/techarticles/detail/25207&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Mar 2013 22:30:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/calculate-field-code-block-vb-help/m-p/498572#M28304</guid>
      <dc:creator>AnthonyGiles</dc:creator>
      <dc:date>2013-03-11T22:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field Code Block VB Help</title>
      <link>https://community.esri.com/t5/data-management-questions/calculate-field-code-block-vb-help/m-p/498573#M28305</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Darrock,&lt;BR /&gt;&lt;BR /&gt;Did you also make the other changes I suggested not just the quotes?&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Anthony&lt;BR /&gt;&lt;BR /&gt;P.S. not sure what version of arcmap your are using but I have just found this article:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://support.esri.com/en/knowledgebase/techarticles/detail/25207"&gt;http://support.esri.com/en/knowledgebase/techarticles/detail/25207&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Yeah I've tried various combinations suggested. I'm using v10.1 SP1; I'll attempt something in Python.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Mar 2013 23:08:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/calculate-field-code-block-vb-help/m-p/498573#M28305</guid>
      <dc:creator>DarrochKaye</dc:creator>
      <dc:date>2013-03-11T23:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field Code Block VB Help</title>
      <link>https://community.esri.com/t5/data-management-questions/calculate-field-code-block-vb-help/m-p/498574#M28306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;A couple things, VBScript does not allow you to explicitly declare any data types; all variables are implicitly Variant. Statements like Dim x as String should be removed or simplified to Dim x. If you want to execute only one statement when a condition is true, you can write the code on one line, otherwise each statement needs to be on a new line ie&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If....Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;statement&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;elseif....Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;statement&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;else statement&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;end if&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Dim temp If [OBJECTID] =1 Then&amp;nbsp; temp = "Very Destructive" elseif [OBJECTID] = 2 Then&amp;nbsp; temp = "Destructive" elseif [OBJECTID] =3 Then&amp;nbsp; temp = "Damaging" else temp ="Nothing" end if&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 23:21:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/calculate-field-code-block-vb-help/m-p/498574#M28306</guid>
      <dc:creator>ChrisFox3</dc:creator>
      <dc:date>2013-03-12T23:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field Code Block VB Help</title>
      <link>https://community.esri.com/t5/data-management-questions/calculate-field-code-block-vb-help/m-p/498575#M28307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;A couple things, VBScript does not allow you to explicitly declare any data types; all variables are implicitly Variant. Statements like Dim x as String should be removed or simplified to Dim x. If you want to execute only one statement when a condition is true, you can write the code on one line, otherwise each statement needs to be on a new line ie&lt;BR /&gt;&lt;BR /&gt;If....Then&lt;BR /&gt;statement&lt;BR /&gt;elseif....Then&lt;BR /&gt;statement&lt;BR /&gt;else statement&lt;BR /&gt;end if&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Dim temp
If [OBJECTID] =1 Then 
temp = "Very Destructive"
elseif [OBJECTID] = 2 Then 
temp = "Destructive"
elseif [OBJECTID] =3 Then 
temp = "Damaging"
else temp ="Nothing"
end if
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Excellent Chris, this works perfectly. Thanks very much.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;DK&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;P.S. Any idea why &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;elseif&lt;/SPAN&gt;&lt;SPAN&gt; is one work but &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;end if&lt;/SPAN&gt;&lt;SPAN&gt; is two?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:54:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/calculate-field-code-block-vb-help/m-p/498575#M28307</guid>
      <dc:creator>DarrochKaye</dc:creator>
      <dc:date>2021-12-11T21:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field Code Block VB Help</title>
      <link>https://community.esri.com/t5/data-management-questions/calculate-field-code-block-vb-help/m-p/498576#M28308</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Excellent Chris, this works perfectly. Thanks very much.&lt;BR /&gt;&lt;BR /&gt;DK&lt;BR /&gt;&lt;BR /&gt;P.S. Any idea why &lt;SPAN style="font-style:italic;"&gt;elseif&lt;/SPAN&gt; is one work but &lt;SPAN style="font-style:italic;"&gt;end if&lt;/SPAN&gt; is two?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am not sure, but this is consistent with all VB languages.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/752y8abs(v=vs.80).aspx"&gt;http://msdn.microsoft.com/en-us/library/752y8abs(v=vs.80).aspx&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Mar 2013 15:12:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/calculate-field-code-block-vb-help/m-p/498576#M28308</guid>
      <dc:creator>ChrisFox3</dc:creator>
      <dc:date>2013-03-13T15:12:34Z</dc:date>
    </item>
  </channel>
</rss>

