{"id":2121,"date":"2022-07-12T10:19:00","date_gmt":"2022-07-12T10:19:00","guid":{"rendered":"https:\/\/www.overcharts.com\/en\/helpcenter\/?post_type=docs&#038;p=2121"},"modified":"2022-11-25T10:52:39","modified_gmt":"2022-11-25T10:52:39","password":"","slug":"overbasic-select-case","status":"publish","type":"docs","link":"https:\/\/www.overcharts.com\/en\/helpcenter\/docs\/overbasic-select-case\/","title":{"rendered":"Overbasic &#8211; Select Case"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">SELECT CASE statement is used to select which code block to execute based on an expression result.<\/p>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Syntax<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Select Case<\/mark><\/strong> &lt;expression>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Case<\/mark><\/strong> &lt;value\/expression>&#91;, &lt;value\/expression>, &lt;value\/expression>]\n    &lt;code block>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Case<\/mark><\/strong> &lt;value\/expression>&#91;, &lt;value\/expression>, &lt;value\/expression>]\n    &lt;code block>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Case<\/mark><\/strong> &lt;value\/expression>&#91;, &lt;value\/expression>, &lt;value\/expression>]\n    &lt;code block>\n&#91;<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Case Else<\/mark><\/strong>]\n    &#91;&lt;code block>]\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">EndSelect<\/mark><\/strong><\/code><\/pre>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<ul class=\"wp-block-list\"><li>&lt;expression>: any numeric expression<\/li><li>The various &lt;value\/expression> in <em>CASEs<\/em> are expressions or numeric values to be compared with the value of &lt;expression>. Each <em>Case<\/em> can have several comma-separated &lt;value\/expression>.<\/li><li>The <strong>Case Else<\/strong> block is <strong><em>optional<\/em><\/strong> and is executed only if no match is found between the value of  &lt;expression> and the various <strong>CASE<\/strong>s<\/li><\/ul>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>How it works<\/strong>:<br>1) The Select Case expression is evaluated once<br>2) The value of &lt;expression> is compared with the values of each <strong>Case<\/strong><br>3) If there is a match, the associated block of code is executed<br>4) If there is NO match, the code block associated with <strong>Case Else<\/strong> is executed (if any).<\/p>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Examples<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'Getting month name based on month number.<\/mark>\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'In this example there is no CASE ELSE.<\/mark>\n\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> month <mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\"><strong>As<\/strong> <strong>Numeric<\/strong><\/mark> = 5\n\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Select <\/mark><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Case<\/mark><\/strong><\/strong> month \n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Case<\/mark><\/strong> 1\n    monthName = \"January\"\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Case<\/mark><\/strong> 2\n    monthName = \"February\"\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Case<\/mark><\/strong> 3\n    monthName = \"March\"\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Case<\/mark><\/strong> 4\n    monthName = \"April\"\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Case<\/mark><\/strong> 5\n    monthName = \"May\"\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Case<\/mark><\/strong> 6\n    monthName = \"June\"\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Case<\/mark><\/strong> 7\n    monthName = \"July\"\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Case<\/mark><\/strong> 8\n    monthName = \"August\"\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Case<\/mark><\/strong> 9\n    monthName = \"September\"\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Case<\/mark><\/strong> 10\n    monthName = \"October\"\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Case<\/mark><\/strong> 11\n    monthName = \"November\"\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Case<\/mark><\/strong> 12\n    monthName = \"December\"\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">EndSelect<\/mark><\/strong>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'The result is: May<\/mark><\/code><\/pre>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code><mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'Getting the days in a month, based on month number<\/mark>\n\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> month <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = 5\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> daysInMonth <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = 0\n\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Select Case<\/mark><\/strong> month \n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Case<\/mark><\/strong> 2  \n    <mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'check if the year is a leap year<\/mark>\n    <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">If<\/mark><\/strong> (Math.Mod(Year, 400) = 0) <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Or<\/mark><\/strong> ((Math.Mod(Year, 4) = 0) <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">And<\/mark><\/strong> (Math.Mod(Year, 100) &lt;> 0)) <mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\"><strong>Then<\/strong><\/mark>\n        daysInMonth = 29\n    <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Else<\/mark><\/strong>\n        daysInMonth = 28\n    <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">EndIf<\/mark><\/strong>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Case<\/mark><\/strong> 4, 6, 9, 11\n    daysInMonth = 30\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Case Else<\/mark><\/strong>\n    daysInMonth = 31\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">EndSelect<\/mark><\/strong>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'The result is: 31<\/mark><\/code><\/pre>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>SELECT CASE statement is used to select which code block to execute based on an expression result. Syntax &lt;expression>: any numeric expression The various &lt;value\/expression> in CASEs are expressions or numeric values to be compared with the value of &lt;expression>. Each Case can have several comma-separated &lt;value\/expression>. The Case Else block is optional and is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"doc_category":[16],"doc_tag":[],"class_list":["post-2121","docs","type-docs","status-publish","hentry","doc_category-syntax-keywords"],"year_month":"2026-10","word_count":298,"total_views":"2","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"name":"Overcharts Team","author_nicename":"overadmin","author_url":"https:\/\/www.overcharts.com\/en\/helpcenter\/author\/overadmin\/"},"doc_category_info":[{"term_name":"Syntax &amp; Keywords","term_url":"https:\/\/www.overcharts.com\/en\/helpcenter\/docs-category\/syntax-keywords\/"}],"doc_tag_info":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\r\n<title>Overbasic - Select Case - Overcharts Help Center<\/title>\r\n<meta name=\"description\" content=\"SELECT CASE statement is used to select which code block to execute based on an expression result.\" \/>\r\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\r\n<link rel=\"canonical\" href=\"https:\/\/www.overcharts.com\/en\/helpcenter\/docs\/overbasic-select-case\/\" \/>\r\n<meta property=\"og:locale\" content=\"en_US\" \/>\r\n<meta property=\"og:type\" content=\"article\" \/>\r\n<meta property=\"og:title\" content=\"Overbasic - Select Case - Overcharts Help Center\" \/>\r\n<meta property=\"og:description\" content=\"SELECT CASE statement is used to select which code block to execute based on an expression result.\" \/>\r\n<meta property=\"og:url\" content=\"https:\/\/www.overcharts.com\/en\/helpcenter\/docs\/overbasic-select-case\/\" \/>\r\n<meta property=\"og:site_name\" content=\"Overcharts Help Center\" \/>\r\n<meta property=\"article:modified_time\" content=\"2022-11-25T10:52:39+00:00\" \/>\r\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\r\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\r\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.overcharts.com\\\/en\\\/helpcenter\\\/docs\\\/overbasic-select-case\\\/\",\"url\":\"https:\\\/\\\/www.overcharts.com\\\/en\\\/helpcenter\\\/docs\\\/overbasic-select-case\\\/\",\"name\":\"Overbasic - Select Case - Overcharts Help Center\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.overcharts.com\\\/en\\\/helpcenter\\\/#website\"},\"datePublished\":\"2022-07-12T10:19:00+00:00\",\"dateModified\":\"2022-11-25T10:52:39+00:00\",\"description\":\"SELECT CASE statement is used to select which code block to execute based on an expression result.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.overcharts.com\\\/en\\\/helpcenter\\\/docs\\\/overbasic-select-case\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.overcharts.com\\\/en\\\/helpcenter\\\/docs\\\/overbasic-select-case\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.overcharts.com\\\/en\\\/helpcenter\\\/docs\\\/overbasic-select-case\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.overcharts.com\\\/en\\\/helpcenter\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Overbasic &#8211; Select Case\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.overcharts.com\\\/en\\\/helpcenter\\\/#website\",\"url\":\"https:\\\/\\\/www.overcharts.com\\\/en\\\/helpcenter\\\/\",\"name\":\"Overcharts Help Center\",\"description\":\"Trading Software &amp; Technical Analysis\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.overcharts.com\\\/en\\\/helpcenter\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Overbasic - Select Case - Overcharts Help Center","description":"SELECT CASE statement is used to select which code block to execute based on an expression result.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.overcharts.com\/en\/helpcenter\/docs\/overbasic-select-case\/","og_locale":"en_US","og_type":"article","og_title":"Overbasic - Select Case - Overcharts Help Center","og_description":"SELECT CASE statement is used to select which code block to execute based on an expression result.","og_url":"https:\/\/www.overcharts.com\/en\/helpcenter\/docs\/overbasic-select-case\/","og_site_name":"Overcharts Help Center","article_modified_time":"2022-11-25T10:52:39+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.overcharts.com\/en\/helpcenter\/docs\/overbasic-select-case\/","url":"https:\/\/www.overcharts.com\/en\/helpcenter\/docs\/overbasic-select-case\/","name":"Overbasic - Select Case - Overcharts Help Center","isPartOf":{"@id":"https:\/\/www.overcharts.com\/en\/helpcenter\/#website"},"datePublished":"2022-07-12T10:19:00+00:00","dateModified":"2022-11-25T10:52:39+00:00","description":"SELECT CASE statement is used to select which code block to execute based on an expression result.","breadcrumb":{"@id":"https:\/\/www.overcharts.com\/en\/helpcenter\/docs\/overbasic-select-case\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.overcharts.com\/en\/helpcenter\/docs\/overbasic-select-case\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.overcharts.com\/en\/helpcenter\/docs\/overbasic-select-case\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.overcharts.com\/en\/helpcenter\/"},{"@type":"ListItem","position":2,"name":"Overbasic &#8211; Select Case"}]},{"@type":"WebSite","@id":"https:\/\/www.overcharts.com\/en\/helpcenter\/#website","url":"https:\/\/www.overcharts.com\/en\/helpcenter\/","name":"Overcharts Help Center","description":"Trading Software &amp; Technical Analysis","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.overcharts.com\/en\/helpcenter\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.overcharts.com\/en\/helpcenter\/wp-json\/wp\/v2\/docs\/2121","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.overcharts.com\/en\/helpcenter\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.overcharts.com\/en\/helpcenter\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/www.overcharts.com\/en\/helpcenter\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.overcharts.com\/en\/helpcenter\/wp-json\/wp\/v2\/comments?post=2121"}],"version-history":[{"count":5,"href":"https:\/\/www.overcharts.com\/en\/helpcenter\/wp-json\/wp\/v2\/docs\/2121\/revisions"}],"predecessor-version":[{"id":2126,"href":"https:\/\/www.overcharts.com\/en\/helpcenter\/wp-json\/wp\/v2\/docs\/2121\/revisions\/2126"}],"wp:attachment":[{"href":"https:\/\/www.overcharts.com\/en\/helpcenter\/wp-json\/wp\/v2\/media?parent=2121"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/www.overcharts.com\/en\/helpcenter\/wp-json\/wp\/v2\/doc_category?post=2121"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.overcharts.com\/en\/helpcenter\/wp-json\/wp\/v2\/doc_tag?post=2121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}