<?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 Script is not working in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/vb-script-is-not-working/m-p/589294#M46170</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="text-align: left;"&gt;That's absolutely wonderful from you Richard. It worked very well for me. I appreciate&amp;nbsp;your time and effort.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 21 Feb 2018 11:45:39 GMT</pubDate>
    <dc:creator>AbdulJabbar1</dc:creator>
    <dc:date>2018-02-21T11:45:39Z</dc:date>
    <item>
      <title>VB Script is not working</title>
      <link>https://community.esri.com/t5/python-questions/vb-script-is-not-working/m-p/589286#M46162</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;Can anyone please have a look in the script below;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If[AssetCondition] = "1 - NEW" Then &lt;BR /&gt;[CONDITION] = "1" &lt;BR /&gt;ElseIf[AssetCondition] = "2 - GOOD" Then &lt;BR /&gt;[CONDITION] = "2"&lt;BR /&gt;ElseIf[AssetCondition] = "3 - POOR" Then &lt;BR /&gt;[CONDITION] = "3"&lt;BR /&gt;ElseIf[AssetCondition] = "4 - UNSERVICEABLE" Then &lt;BR /&gt;[CONDITION] = "4"&lt;BR /&gt;Else [CONDITION] = "NULL" &lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's not working. Any assistance will be highly appreciated, thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Feb 2018 18:08:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/vb-script-is-not-working/m-p/589286#M46162</guid>
      <dc:creator>AbdulJabbar1</dc:creator>
      <dc:date>2018-02-20T18:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: VB Script is not working</title>
      <link>https://community.esri.com/t5/python-questions/vb-script-is-not-working/m-p/589287#M46163</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not much on VB script these days, but I'm pretty sure you need indents.&amp;nbsp; See&amp;nbsp;&lt;A class="link-titled" href="https://ss64.com/vb/if.html" title="https://ss64.com/vb/if.html"&gt;If ... Then...Else - VBScript - SS64.com&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You might get a better response if this were posted in something other than the Python section&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Feb 2018 18:15:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/vb-script-is-not-working/m-p/589287#M46163</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2018-02-20T18:15:20Z</dc:date>
    </item>
    <item>
      <title>Re: VB Script is not working</title>
      <link>https://community.esri.com/t5/python-questions/vb-script-is-not-working/m-p/589288#M46164</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What isn't working?&amp;nbsp; An error message or just unexpected results?&amp;nbsp; If the former, what is the error message?&amp;nbsp; If the latter, what are you expecting vs what you are seeing?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Feb 2018 18:15:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/vb-script-is-not-working/m-p/589288#M46164</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2018-02-20T18:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: VB Script is not working</title>
      <link>https://community.esri.com/t5/python-questions/vb-script-is-not-working/m-p/589289#M46165</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You don't mention the software or version you are tryin gto work with, but maybe you need the VBA Compatibility?&amp;nbsp; I had to go back to the 10.4.1 download (on myesri) to find the last available version for Desktop.&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/397033_pastedImage_1.png" style="width: 620px; height: 83px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Feb 2018 18:22:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/vb-script-is-not-working/m-p/589289#M46165</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2018-02-20T18:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: VB Script is not working</title>
      <link>https://community.esri.com/t5/python-questions/vb-script-is-not-working/m-p/589290#M46166</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Indeed, the newer versions of ArcGIS don't support VBA. You should really convert your VBA logic to Python.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; !AssetCondition! &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"1 - NEW"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; !CCONDITION! &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"1"&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;elif&lt;/SPAN&gt; !AssetCondition! &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="string token"&gt;"2 - GOOD"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; !CCONDITION! &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"2"&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;elif&lt;/SPAN&gt; !AssetCondition! &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="string token"&gt;"3 - POOR"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; !CCONDITION! &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"3"&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;elif&lt;/SPAN&gt; !AssetCondition! &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="string token"&gt;"4 - UNSERVICEABLE"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; !CCONDITION! &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"4"&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; !CONDITION! &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; None&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:18:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/vb-script-is-not-working/m-p/589290#M46166</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-12-12T01:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: VB Script is not working</title>
      <link>https://community.esri.com/t5/python-questions/vb-script-is-not-working/m-p/589291#M46167</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have several comments.&amp;nbsp; If you are using the Field Calculator you cannot set a field value in VB Script with an expression like:&lt;/P&gt;&lt;P&gt;[CONDITION] = "1"&lt;/P&gt;&lt;P&gt;You can only set a field value by doing a calculation on that field.&amp;nbsp; Field names in brackets are read only.&lt;/P&gt;&lt;P&gt;You need to make the output of the calculation a variable name, not a field name.&amp;nbsp; I use the variable Output in all my Pre-Logic VB calculations. You need a space after keywords like If and ElseIf.&amp;nbsp; Else should be by itself in a multiline If Else Then expression.&amp;nbsp; Null is not quoted if you want a real Null value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the Field Calculator set up you need to use while doing the calculation on the CONDITION field:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Parser: VB Script&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Show Codeblock checked&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pre-Logic Script Code:&lt;/P&gt;&lt;P&gt;If [AssetCondition] = "1 - NEW" Then &lt;BR /&gt;Output = "1" &lt;BR /&gt;ElseIf [AssetCondition] = "2 - GOOD" Then &lt;BR /&gt;Output = "2"&lt;BR /&gt;ElseIf [AssetCondition] = "3 - POOR" Then &lt;BR /&gt;Output = "3"&lt;BR /&gt;ElseIf [AssetCondition] = "4 - UNSERVICEABLE" Then &lt;BR /&gt;Output = "4"&lt;BR /&gt;Else&lt;BR /&gt;Output = Null&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CONDITION =&lt;/P&gt;&lt;P&gt;Output&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Feb 2018 21:52:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/vb-script-is-not-working/m-p/589291#M46167</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2018-02-20T21:52:31Z</dc:date>
    </item>
    <item>
      <title>Re: VB Script is not working</title>
      <link>https://community.esri.com/t5/python-questions/vb-script-is-not-working/m-p/589292#M46168</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This Python expression won't work in the field calculator.&amp;nbsp; You need to declare it indented under a def method you have named and you need to have passed all of the field values in through that method.&amp;nbsp; Like VB Script, you can only set a field value by doing a calculation on a field and returning a value from your Pre-Logic Script code, not by using an expression internal to the calculation like:&lt;/P&gt;&lt;P&gt;!Condition! = "1"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So in Python it would be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Parser: Python&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Show Codeblock checked&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PreLogic Script Code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;def setCondition(assetCondition):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if assetCondition == "1 - NEW":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "1"
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif assetCondition ==&amp;nbsp; "2 - GOOD":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "2"
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif assetCondition ==&amp;nbsp; "3 - POOR":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "3"
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif assetCondition ==&amp;nbsp; "4 - UNSERVICEABLE":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "4"
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return None‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Condition =&lt;/P&gt;&lt;P&gt;setCondition(!AssetCondition!)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:18:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/vb-script-is-not-working/m-p/589292#M46168</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-12T01:18:48Z</dc:date>
    </item>
    <item>
      <title>Re: VB Script is not working</title>
      <link>https://community.esri.com/t5/python-questions/vb-script-is-not-working/m-p/589293#M46169</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good point, &lt;A href="https://community.esri.com/migrated-users/4811"&gt;Richard Fairhurst&lt;/A&gt;.&amp;nbsp;My intention was just to show a simple like for like comparison of the VB code with Python.&amp;nbsp;Thanks for clarifying and making a working example for &lt;A href="https://community.esri.com/people/colasuk"&gt;colasuk&lt;/A&gt;‌.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Feb 2018 23:54:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/vb-script-is-not-working/m-p/589293#M46169</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2018-02-20T23:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: VB Script is not working</title>
      <link>https://community.esri.com/t5/python-questions/vb-script-is-not-working/m-p/589294#M46170</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="text-align: left;"&gt;That's absolutely wonderful from you Richard. It worked very well for me. I appreciate&amp;nbsp;your time and effort.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Feb 2018 11:45:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/vb-script-is-not-working/m-p/589294#M46170</guid>
      <dc:creator>AbdulJabbar1</dc:creator>
      <dc:date>2018-02-21T11:45:39Z</dc:date>
    </item>
  </channel>
</rss>

