<?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: VB conditional statement not working in calculate field tool in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/vb-conditional-statement-not-working-in-calculate/m-p/153640#M11869</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Great post, perfect solution that saved me hours of head scratching. Thanks for taking the time to post the solution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Paulg&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 06 Jul 2011 13:23:17 GMT</pubDate>
    <dc:creator>PaulGrimes</dc:creator>
    <dc:date>2011-07-06T13:23:17Z</dc:date>
    <item>
      <title>VB conditional statement not working in calculate field tool</title>
      <link>https://community.esri.com/t5/python-questions/vb-conditional-statement-not-working-in-calculate/m-p/153636#M11865</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am writing a python script which utilizes the expression &amp;amp; code block parameter in the calculate field tool to populate values for a specific field. The code block uses a conditional If,Then, Else statement to understand the value of an existing field (Num_Value) in order to calculate the value of another field (Num_Text). However, I keep receiving the error "(Microsoft VBScript compilation error) Expected end of statement". See script below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CodeBlock = "dim X as string \\nIf [Num_Value] = 1 Then \\nX = \"Poor\" \\nElse X = \"Good\" \\nEnd If"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.CalculateField_management(InputFeature,"Num_Text","X","VB",CodeBlock)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas as to what I am doing wrong within the VB code block??&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help is greatly appreciated!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;P.S. Using arcmap 9.2&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 May 2011 16:11:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/vb-conditional-statement-not-working-in-calculate/m-p/153636#M11865</guid>
      <dc:creator>CrystalCarreon</dc:creator>
      <dc:date>2011-05-24T16:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: VB conditional statement not working in calculate field tool</title>
      <link>https://community.esri.com/t5/python-questions/vb-conditional-statement-not-working-in-calculate/m-p/153637#M11866</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I using ArcGIS 10, so I can't test this. But, in 10 you can use VBScript for the code block (although I'm not completely sure what 9.2 uses - the help says standard VB). I know that VBScript doesn't like it when you dim variables AS a datatype. I suggest either not dimming your variable, or at least remove "as string".&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 May 2011 18:03:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/vb-conditional-statement-not-working-in-calculate/m-p/153637#M11866</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2011-05-24T18:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: VB conditional statement not working in calculate field tool</title>
      <link>https://community.esri.com/t5/python-questions/vb-conditional-statement-not-working-in-calculate/m-p/153638#M11867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That did the trick! Thanks so much!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I used that bit of code just within ArcMap it worked fine so I figured I would include it but I guess not!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 May 2011 18:26:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/vb-conditional-statement-not-working-in-calculate/m-p/153638#M11867</guid>
      <dc:creator>CrystalCarreon</dc:creator>
      <dc:date>2011-05-24T18:26:31Z</dc:date>
    </item>
    <item>
      <title>Re: VB conditional statement not working in calculate field tool</title>
      <link>https://community.esri.com/t5/python-questions/vb-conditional-statement-not-working-in-calculate/m-p/153639#M11868</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;No problem - I've spent a lot of time tilting at that windmill in the past!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 May 2011 18:57:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/vb-conditional-statement-not-working-in-calculate/m-p/153639#M11868</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2011-05-24T18:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: VB conditional statement not working in calculate field tool</title>
      <link>https://community.esri.com/t5/python-questions/vb-conditional-statement-not-working-in-calculate/m-p/153640#M11869</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Great post, perfect solution that saved me hours of head scratching. Thanks for taking the time to post the solution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Paulg&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Jul 2011 13:23:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/vb-conditional-statement-not-working-in-calculate/m-p/153640#M11869</guid>
      <dc:creator>PaulGrimes</dc:creator>
      <dc:date>2011-07-06T13:23:17Z</dc:date>
    </item>
  </channel>
</rss>

