<?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 So I have this VBScript in labeling that I'm trying to convert to Arcade but didn't get it solution. in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/so-i-have-this-vbscript-in-labeling-that-i-m/m-p/1360771#M6864</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have any coveter tool if you have any please send me that,&lt;/P&gt;&lt;P&gt;Below mention the VB scripts code, Please someone can you help me that.&lt;/P&gt;&lt;P&gt;Dim result&lt;BR /&gt;If [Detect]= "N" and [Pre_Detect]= "N" then&lt;BR /&gt;result = [TextstringEdit] &amp;amp;vbnewline&amp;amp; [Post] &amp;amp;"&amp;lt;ITA&amp;gt;/"&amp;amp; [Pre_Post] &amp;amp;"&amp;lt;/ITA&amp;gt;"&lt;BR /&gt;ElseIf [Detect]= "N" and [Pre_Detect]= "Y" then&lt;BR /&gt;result= [TextstringEdit] &amp;amp;vbnewline&amp;amp; [Post] &amp;amp;"&amp;lt;BOL&amp;gt;&amp;lt;ITA&amp;gt;/"&amp;amp; [Pre_Post] &amp;amp;"&amp;lt;/ITA&amp;gt;&amp;lt;/BOL&amp;gt;"&lt;BR /&gt;ElseIf [Detect]= "Y" and [Pre_Detect]= "N" then&lt;BR /&gt;result = [TextstringEdit] &amp;amp;vbnewline&amp;amp; "&amp;lt;BOL&amp;gt;"&amp;amp; [Post] &amp;amp;"&amp;lt;/BOL&amp;gt;"&amp;amp;"&amp;lt;ITA&amp;gt;/"&amp;amp; [Pre_Post] &amp;amp;"&amp;lt;/ITA&amp;gt;"&lt;BR /&gt;ElseIf [Detect]= "Y" and [Pre_Detect]= "Y" then&lt;BR /&gt;result = [TextstringEdit] &amp;amp;vbnewline&amp;amp; "&amp;lt;BOL&amp;gt;"&amp;amp; [Post] &amp;amp;"&amp;lt;/BOL&amp;gt;"&amp;amp;"&amp;lt;BOL&amp;gt;&amp;lt;ITA&amp;gt;/"&amp;amp; [Pre_Post] &amp;amp;"&amp;lt;/ITA&amp;gt;&amp;lt;/BOL&amp;gt;"&lt;BR /&gt;Else result = "Error in result"&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;__esri_field_calculator_splitter__&lt;BR /&gt;result&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Rajesh M&lt;/P&gt;&lt;P&gt;remoterajesh@gmail.com&lt;/P&gt;</description>
    <pubDate>Thu, 14 Dec 2023 08:41:38 GMT</pubDate>
    <dc:creator>Rajeshmadhaiyan</dc:creator>
    <dc:date>2023-12-14T08:41:38Z</dc:date>
    <item>
      <title>So I have this VBScript in labeling that I'm trying to convert to Arcade but didn't get it solution.</title>
      <link>https://community.esri.com/t5/developers-questions/so-i-have-this-vbscript-in-labeling-that-i-m/m-p/1360771#M6864</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have any coveter tool if you have any please send me that,&lt;/P&gt;&lt;P&gt;Below mention the VB scripts code, Please someone can you help me that.&lt;/P&gt;&lt;P&gt;Dim result&lt;BR /&gt;If [Detect]= "N" and [Pre_Detect]= "N" then&lt;BR /&gt;result = [TextstringEdit] &amp;amp;vbnewline&amp;amp; [Post] &amp;amp;"&amp;lt;ITA&amp;gt;/"&amp;amp; [Pre_Post] &amp;amp;"&amp;lt;/ITA&amp;gt;"&lt;BR /&gt;ElseIf [Detect]= "N" and [Pre_Detect]= "Y" then&lt;BR /&gt;result= [TextstringEdit] &amp;amp;vbnewline&amp;amp; [Post] &amp;amp;"&amp;lt;BOL&amp;gt;&amp;lt;ITA&amp;gt;/"&amp;amp; [Pre_Post] &amp;amp;"&amp;lt;/ITA&amp;gt;&amp;lt;/BOL&amp;gt;"&lt;BR /&gt;ElseIf [Detect]= "Y" and [Pre_Detect]= "N" then&lt;BR /&gt;result = [TextstringEdit] &amp;amp;vbnewline&amp;amp; "&amp;lt;BOL&amp;gt;"&amp;amp; [Post] &amp;amp;"&amp;lt;/BOL&amp;gt;"&amp;amp;"&amp;lt;ITA&amp;gt;/"&amp;amp; [Pre_Post] &amp;amp;"&amp;lt;/ITA&amp;gt;"&lt;BR /&gt;ElseIf [Detect]= "Y" and [Pre_Detect]= "Y" then&lt;BR /&gt;result = [TextstringEdit] &amp;amp;vbnewline&amp;amp; "&amp;lt;BOL&amp;gt;"&amp;amp; [Post] &amp;amp;"&amp;lt;/BOL&amp;gt;"&amp;amp;"&amp;lt;BOL&amp;gt;&amp;lt;ITA&amp;gt;/"&amp;amp; [Pre_Post] &amp;amp;"&amp;lt;/ITA&amp;gt;&amp;lt;/BOL&amp;gt;"&lt;BR /&gt;Else result = "Error in result"&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;__esri_field_calculator_splitter__&lt;BR /&gt;result&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Rajesh M&lt;/P&gt;&lt;P&gt;remoterajesh@gmail.com&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 08:41:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/so-i-have-this-vbscript-in-labeling-that-i-m/m-p/1360771#M6864</guid>
      <dc:creator>Rajeshmadhaiyan</dc:creator>
      <dc:date>2023-12-14T08:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: So I have this VBScript in labeling that I'm trying to convert to Arcade but didn't get it solution.</title>
      <link>https://community.esri.com/t5/developers-questions/so-i-have-this-vbscript-in-labeling-that-i-m/m-p/1360897#M6865</link>
      <description>&lt;P&gt;I don't know any automatic converters out there, but rewriting your conditions is simple enough.&lt;/P&gt;&lt;P&gt;Instead of "If condition then do something", you write "If(condition){do something}"&lt;/P&gt;&lt;P&gt;Text formatting in Arcade is easy as well. To build out a string, you can just separate your strings / string variables with "+" operators, and vbnewline can be replaced with textformatting.newline, &amp;lt;br&amp;gt;, or \n, depending on where the script is evaluating.&lt;/P&gt;&lt;P&gt;A direct translation would look like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var result

if ($feature.Detect == 'N' &amp;amp;&amp;amp; $feature.Pre_Detect == 'N') {
  result = $feature.TextstringEdit + '\n' + $feature.Post + '&amp;lt;ITA&amp;gt;' + $feature.Pre_Post + '&amp;lt;/ITA&amp;gt;'
} else if ($feature.Detect == 'N' &amp;amp;&amp;amp; $feature.Pre_Detect == 'Y') {
  result = $feature.TextstringEdit + '\n' + $feature.Post + '&amp;lt;BOL&amp;gt;&amp;lt;ITA&amp;gt;' + $feature.Pre_Post + '&amp;lt;/ITA&amp;gt;&amp;lt;/BOL&amp;gt;'
} else if ($feature.Detect == 'Y' &amp;amp;&amp;amp; $feature.Pre_Detect == 'N') {
  result = $feature.TextstringEdit + '\n&amp;lt;BOL&amp;gt;' + $feature.Post + '&amp;lt;/BOL&amp;gt;&amp;lt;ITA&amp;gt;' + $feature.Pre_Post + '&amp;lt;/ITA&amp;gt;'
} else if ($feature.Detect == 'Y' &amp;amp;&amp;amp; $feature.Pre_Detect == 'Y') {
  result = $feature.TextstringEdit + '\n&amp;lt;BOL&amp;gt;' + $feature.Post + '&amp;lt;/BOL&amp;gt;&amp;lt;BOL&amp;gt;&amp;lt;ITA&amp;gt;' + $feature.Pre_Post + '&amp;lt;/ITA&amp;gt;&amp;lt;/BOL&amp;gt;'
} else {
  result = "Error in result"
}

return result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But we can make some serious improvements to this in Arcade. For one, let's assign your attributes to variables. Instead of typing out "$feature.TextstringEdit" every time, we could have something shorter.&lt;/P&gt;&lt;P&gt;Second, we can use template literals for strings with variables piped in and do away with all of those + operators.&lt;/P&gt;&lt;P&gt;Here's what it looks like with those two things implemented. The code is taller, but not as wide, and a bit more readable.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var result

var detect = $feature.Detect
var predetect = $feature.Pre_Detect

var tse = $feature.TextstringEdit
var post = $feature.Post
var prepost = $feature.Pre_Post

if (detect == 'N' &amp;amp;&amp;amp; predetect == 'N') {
  result = `${tse}\n${post}&amp;lt;ITA&amp;gt;${prepost}&amp;lt;/ITA&amp;gt;`
} else if (detect == 'N' &amp;amp;&amp;amp; predetect == 'Y') {
  result = `${tse}\n${post}&amp;lt;BOL&amp;gt;&amp;lt;ITA&amp;gt;${prepost}&amp;lt;/ITA&amp;gt;&amp;lt;/BOL&amp;gt;`
} else if (detect == 'Y' &amp;amp;&amp;amp; predetect == 'N') {
  result = `${tse}\n&amp;lt;BOL&amp;gt;${post}&amp;lt;/BOL&amp;gt;&amp;lt;ITA&amp;gt;${prepost}&amp;lt;/ITA&amp;gt;`
} else if (detect == 'Y' &amp;amp;&amp;amp; predetect == 'Y') {
  result = `${tse}\n&amp;lt;BOL&amp;gt;${post}&amp;lt;/BOL&amp;gt;&amp;lt;BOL&amp;gt;&amp;lt;ITA&amp;gt;${prepost}&amp;lt;/ITA&amp;gt;&amp;lt;/BOL&amp;gt;`
} else {
  result = "Error in result"
}

return result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But we can go further! Since you're just checking if those two fields are "Y" or "N", we can actually do the check in the variable assignment, which makes our "detect" and "predetect" variables &lt;EM&gt;booleans&lt;/EM&gt;. Using them in a condition is much more concise that way. "predetect == 'N'" becomes "!predetect".&lt;/P&gt;&lt;P&gt;Further, a long if/else block that is being used to set a single parameter can be written with a &lt;STRONG&gt;When&lt;/STRONG&gt; function. Long if/else blocks are better suited to cases where you are literally doing different things based on the condition.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var detect = $feature.Detect == 'Y'
var predetect = $feature.Pre_Detect == 'Y'

var tse = $feature.TextstringEdit
var post = $feature.Post
var prepost = $feature.Pre_Post

return When(
  !detect &amp;amp;&amp;amp; !predetect, `${tse}\n${post}&amp;lt;ITA&amp;gt;${prepost}&amp;lt;/ITA&amp;gt;`,
  !detect &amp;amp;&amp;amp; predetect,  `${tse}\n${post}&amp;lt;BOL&amp;gt;&amp;lt;ITA&amp;gt;${prepost}&amp;lt;/ITA&amp;gt;&amp;lt;/BOL&amp;gt;`,
  detect  &amp;amp;&amp;amp; !predetect, `${tse}\n&amp;lt;BOL&amp;gt;${post}&amp;lt;/BOL&amp;gt;&amp;lt;ITA&amp;gt;${prepost}&amp;lt;/ITA&amp;gt;`,
  detect  &amp;amp;&amp;amp; predetect,  `${tse}\n&amp;lt;BOL&amp;gt;${post}&amp;lt;/BOL&amp;gt;&amp;lt;BOL&amp;gt;&amp;lt;ITA&amp;gt;${prepost}&amp;lt;/ITA&amp;gt;&amp;lt;/BOL&amp;gt;`,
  "Error in result"
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And we can actually go one more step. Looking at what your expression is actually &lt;EM&gt;doing&lt;/EM&gt;, it appears that when detect is 'Y', the "post" attribute is bold, and the same for pre_detect and "pre_post". Rather than doing an if/else or When series of conditions for each unique combination, we can do each of these separately, then combine them at the end.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var detect = $feature.Detect == 'Y'
var predetect = $feature.Pre_Detect == 'Y'

var tse = $feature.TextstringEdit
var post = $feature.Post
var prepost = `&amp;lt;ITA&amp;gt;${$feature.Pre_Post}&amp;lt;/ITA&amp;gt;`

var post_string = Iif(
  detect,
  `&amp;lt;BOL&amp;gt;${post}&amp;lt;/BOL&amp;gt;`,
  post
)

var prepost_string = Iif(
  predetect,
  `&amp;lt;BOL&amp;gt;${prepost}&amp;lt;/BOL&amp;gt;`,
  prepost
)

return `${tse}
${post_string} ${prepost_string}`&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 15:15:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/so-i-have-this-vbscript-in-labeling-that-i-m/m-p/1360897#M6865</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-12-14T15:15:58Z</dc:date>
    </item>
    <item>
      <title>Re: So I have this VBScript in labeling that I'm trying to convert to Arcade but didn't get it solution.</title>
      <link>https://community.esri.com/t5/developers-questions/so-i-have-this-vbscript-in-labeling-that-i-m/m-p/1374229#M6920</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thank you so much! This is very helpful &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/472460"&gt;@Josh&lt;/a&gt; Carlson.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I will check it that code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2024 01:00:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/so-i-have-this-vbscript-in-labeling-that-i-m/m-p/1374229#M6920</guid>
      <dc:creator>Rajeshmadhaiyan</dc:creator>
      <dc:date>2024-01-25T01:00:07Z</dc:date>
    </item>
    <item>
      <title>Re: So I have this VBScript in labeling that I'm trying to convert to Arcade but didn't get it solution.</title>
      <link>https://community.esri.com/t5/developers-questions/so-i-have-this-vbscript-in-labeling-that-i-m/m-p/1374233#M6921</link>
      <description>&lt;H1&gt;Converting VBScript to Arcade&lt;/H1&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So I have this VBScript in labeling that I'm trying to convert to Arcade,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;VBScribt expression:&amp;nbsp;[TextStringEdit] &amp;amp;vbnewline&amp;amp;"&amp;lt;CLR black='100'&amp;gt;"&amp;amp; [Post]&amp;amp;"&amp;lt;/CLR&amp;gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Rajesh M&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2024 01:24:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/so-i-have-this-vbscript-in-labeling-that-i-m/m-p/1374233#M6921</guid>
      <dc:creator>Rajeshmadhaiyan</dc:creator>
      <dc:date>2024-01-25T01:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: So I have this VBScript in labeling that I'm trying to convert to Arcade but didn't get it solution.</title>
      <link>https://community.esri.com/t5/developers-questions/so-i-have-this-vbscript-in-labeling-that-i-m/m-p/1641919#M7576</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hello Josh Carlson,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have checked the below code it's working good.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It's code come output like. but missing for "/".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;2345&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Rajeshmadhaiyan_1-1755171850562.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/138534iD02E566E7D3743DF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Rajeshmadhaiyan_1-1755171850562.png" alt="Rajeshmadhaiyan_1-1755171850562.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to come to below output.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Rajeshmadhaiyan_0-1755171782310.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/138533i83071A13FEBB2E5A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Rajeshmadhaiyan_0-1755171782310.png" alt="Rajeshmadhaiyan_0-1755171782310.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;===================================================&lt;/P&gt;&lt;P&gt;var result&lt;/P&gt;&lt;P&gt;if ($feature.Detect == 'N' &amp;amp;&amp;amp; $feature.Pre_Detect == 'N') {&lt;BR /&gt;result = $feature.TextstringEdit + '\n' + $feature.Post + '&amp;lt;ITA&amp;gt;' + $feature.Pre_Post + '&amp;lt;/ITA&amp;gt;'&lt;BR /&gt;} else if ($feature.Detect == 'N' &amp;amp;&amp;amp; $feature.Pre_Detect == 'Y') {&lt;BR /&gt;result = $feature.TextstringEdit + '\n' + $feature.Post + '&amp;lt;BOL&amp;gt;&amp;lt;ITA&amp;gt;' + $feature.Pre_Post + '&amp;lt;/ITA&amp;gt;&amp;lt;/BOL&amp;gt;'&lt;BR /&gt;} else if ($feature.Detect == 'Y' &amp;amp;&amp;amp; $feature.Pre_Detect == 'N') {&lt;BR /&gt;result = $feature.TextstringEdit + '\n&amp;lt;BOL&amp;gt;' + $feature.Post + '&amp;lt;/BOL&amp;gt;&amp;lt;ITA&amp;gt;' + $feature.Pre_Post + '&amp;lt;/ITA&amp;gt;'&lt;BR /&gt;} else if ($feature.Detect == 'Y' &amp;amp;&amp;amp; $feature.Pre_Detect == 'Y') {&lt;BR /&gt;result = $feature.TextstringEdit + '\n&amp;lt;BOL&amp;gt;' + $feature.Post + '&amp;lt;/BOL&amp;gt;&amp;lt;BOL&amp;gt;&amp;lt;ITA&amp;gt;' + $feature.Pre_Post + '&amp;lt;/ITA&amp;gt;&amp;lt;/BOL&amp;gt;'&lt;BR /&gt;} else {&lt;BR /&gt;result = "Error in result"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;return result&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Rajesh M&lt;/P&gt;</description>
      <pubDate>Thu, 14 Aug 2025 11:44:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/so-i-have-this-vbscript-in-labeling-that-i-m/m-p/1641919#M7576</guid>
      <dc:creator>Rajeshmadhaiyan</dc:creator>
      <dc:date>2025-08-14T11:44:46Z</dc:date>
    </item>
  </channel>
</rss>

