{"id":2383,"date":"2013-02-13T12:18:13","date_gmt":"2013-02-13T04:18:13","guid":{"rendered":"http:\/\/www.vbtutor.net\/index.php\/"},"modified":"2018-06-24T18:01:01","modified_gmt":"2018-06-24T10:01:01","slug":"visual-basic-2012-lesson-13-function-part-ii","status":"publish","type":"page","link":"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-13-function-part-ii\/","title":{"rendered":"Visual Basic 2012 Lesson 13- The Built-In Functions"},"content":{"rendered":"<h4 style=\"text-align: center;\"><strong><a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-12-functions-part-1\/\">[Lesson 12]<\/a> <\/strong>&lt;&lt;\u00a0<strong><a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-tutorial\/\">[CONTENTS]<\/a> &gt;&gt;<a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-14-functions-part-iii-math-functions\/\"> [Lesson 14]<\/a><\/strong><\/h4>\n<p>There are many built-in functions In Visual Basic 2012. In this lesson, you\u00a0will learn a couple of built-in functions that deal with string manipulation.<\/p>\n<h3>13.1 The Mid Function<\/h3>\n<p>The Mid function is used to retrieve a part of the text from a given phrase. The syntax of the Mid Function is<\/p>\n<pre style=\"font-size: 110%;\">Mid(phrase, position,n)\r\n<\/pre>\n<p>*phrase is the string from which a part of the text is to be retrieved<br \/>\n*position is the starting position of the phrase from which the retrieving process begins.<br \/>\n*n is the number of characters to retrieve.<\/p>\n<p><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br \/>\n<ins class=\"adsbygoogle\" style=\"display: block; text-align: center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-3033628290023372\" data-ad-slot=\"1777484012\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><\/p>\n<h4>Example 13.1<\/h4>\n<pre style=\"font-size: 110%;\">Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click\r\nDim myPhrase As String\r\n myPhrase = Microsoft.VisualBasic.InputBox(\"Enter your phrase\")\r\n Label1.Text = Mid(myPhrase, 2, 6)\r\nEnd Sub\r\n<\/pre>\n<p>* This program will extract text starting from position 2 of the phrase and the number of characters extracted is 6.<\/p>\n<p>The figures are shown below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_13_1.gif\" alt=\"visual basic 2012\" width=\"369\" height=\"156\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_13_2.gif\" alt=\"visual basic 2012\" width=\"300\" height=\"300\" \/><\/p>\n<h3>13.2 The Right Function<\/h3>\n<p>The Right function extracts the right portion of a phrase. The format is<\/p>\n<pre style=\"font-size: 110%; width: 70%;\">Microsoft.Visualbasic.Right (\"Phrase\", n)\r\n<\/pre>\n<p>Where n is the starting position from the right of the phase where the portion of the phrase is going to be extracted. For example:<\/p>\n<pre style=\"font-size: 110%;\">Microsoft.Visualbasic.Right (\"Visual Basic\", 4) = asic\r\n<\/pre>\n<h4>Example 13.2<\/h4>\n<p>The following code extracts the right portion any phrase entered by the user.<\/p>\n<pre style=\"font-size: 110%;\">Private Sub Button1_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click\r\nDim myword As String\r\n myword = TextBox1.Text\r\n Label1.Text = Microsoft.VisualBasic.Right (myword, 4)\r\nEnd Sub\r\n<\/pre>\n<p><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br \/>\n<ins class=\"adsbygoogle\" style=\"display: block; text-align: center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-3033628290023372\" data-ad-slot=\"1777484012\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><\/p>\n<h3>13.3 The Left Function<\/h3>\n<p>The Left function extracts the left portion of a phrase. The format is<\/p>\n<pre style=\"font-size: 110%; width: 70%;\">Microsoft.Visualbasic.Right (\"Phrase\", n)\r\n<\/pre>\n<p>Where n is the starting position from the left of the phase where the portion of the phrase is going to be extracted. For example:<\/p>\n<pre style=\"font-size: 110%;\">Microsoft.Visualbasic.Left(\"Visual Basic\", 4) = asic\r\n<\/pre>\n<h4>Example 13<\/h4>\n<p>The following code extracts the left portion any phrase entered by the user.<\/p>\n<pre style=\"font-size: 110%;\">Private Sub Button1_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click\r\nDim myword As String\r\n myword = TextBox1.Text\r\n Label1.Text = Microsoft.VisualBasic.Left (myword, 4)\r\nEnd Sub\r\n<\/pre>\n<h3>13.4 The Trim Function<\/h3>\n<p>The Trim function trims the empty spaces on both sides of the phrase. The format is<\/p>\n<pre style=\"font-size: 110%; width: 50%;\">Trim(\"Phrase\")\r\n<\/pre>\n<p>.For example, Trim (&#8221; Visual Basic &#8220;) = Visual basic<\/p>\n<h4>Example 13.4<\/h4>\n<pre style=\"font-size: 110%;\">Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click\r\nDim myPhrase As String\r\n myPhrase = Microsoft.VisualBasic.InputBox(\"Enter your phrase\")\r\n Label1.Text = Trim(myPhrase)\r\nEnd Sub\r\n<\/pre>\n<h3>13.5 The Ltrim Function<\/h3>\n<p>The Ltrim function trims the empty spaces of the left portion of the phrase. The format is<\/p>\n<pre style=\"font-size: 110%; width: 50%;\">Ltrim(\"Phrase\")\r\n<\/pre>\n<p>.For example,<\/p>\n<pre style=\"font-size: 110%;\">Ltrim (\" Visual Basic 2012\")= Visual basic 2012\r\n<\/pre>\n<h3>13.6 The Rtrim Function<\/h3>\n<p>The Rtrim function trims the empty spaces of the right portion of the phrase. The format is<\/p>\n<pre style=\"font-size: 110%; width: 50%;\">Rtrim(\"Phrase\")\r\n<\/pre>\n<p>.For example,<\/p>\n<pre style=\"font-size: 110%;\">Rtrim (\"Visual Basic 2012 \") = Visual Basic 2012\r\n<\/pre>\n<p><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br \/>\n<ins class=\"adsbygoogle\" style=\"display: block; text-align: center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-3033628290023372\" data-ad-slot=\"1777484012\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><\/p>\n<h3>13.7 The InStr function<\/h3>\n<p>The InStr function looks for a phrase that is embedded within the original phrase and returns the starting position of the embedded phrase. The format is<\/p>\n<pre style=\"font-size: 110%;\">Instr (n, original phase, embedded phrase)\r\n<\/pre>\n<p>Where n is the position where the Instr function will begin to look for the embedded phrase. For example<\/p>\n<pre style=\"font-size: 110%;\">Instr(1, \"Visual Basic 2012 \",\"Basic\")=8\r\n<\/pre>\n<p>*The function returns a numeric value.<\/p>\n<p>You can write a program code as shown below:<\/p>\n<pre style=\"font-size: 110%;\">Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click\r\n Label1.Text = InStr(1, \"Visual Basic\", \"Basic\")\r\nEnd Sub\r\n<\/pre>\n<h3>13.8 The Ucase and the Lcase Functions<\/h3>\n<p>The Ucase function converts all the characters of a string to capital letters. On the other hand, the Lcase function converts all the characters of a string to small letters.<\/p>\n<p>The syntax is<\/p>\n<pre style=\"font-size: 110%; width: 50%;\">Microsoft.VisualBasic.UCase(Phrase)\r\n\r\nMicrosoft.VisualBasic.LCase(Phrase)\r\n<\/pre>\n<p>For example,<\/p>\n<pre style=\"font-size: 110%;\">Microsoft.VisualBasic.Ucase(\"Visual Basic\") =VISUAL BASIC\r\n\r\nMicrosoft.VisualBasic.Lcase(\"Visual Basic\") =visual basic\r\n<\/pre>\n<h3>13.9 The Chr and the Asc functions<\/h3>\n<p>The Chr function returns the string that corresponds to an ASCII code while the Asc function converts an ASCII character or symbol to the corresponding ASCII code. ASCII stands for &#8220;American Standard Code for Information Interchange&#8221;. Altogether there are 255 ASCII codes and as many ASCII characters. Some of the characters may not be displayed as they may represent some actions such as the pressing of a key or produce a beep sound. The format of the Chr function is<\/p>\n<pre style=\"font-size: 110%; width: 50%;\">Chr(charcode)\r\n<\/pre>\n<p>and the format of the Asc function is<\/p>\n<pre style=\"font-size: 110%; width: 50%;\">Asc(Character)\r\n<\/pre>\n<p>The following are some examples:<\/p>\n<pre style=\"font-size: 110%; width: 50%;\">Chr(65)=A, Chr(122)=z, Chr(37)=% ,\r\n\r\nAsc(\"B\")=66, Asc(\"&amp;\")=38\r\n\r\n<\/pre>\n<p><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br \/>\n<ins class=\"adsbygoogle\" style=\"display: block;\" data-ad-format=\"autorelaxed\" data-ad-client=\"ca-pub-3033628290023372\" data-ad-slot=\"6598395509\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><\/p>\n<h4 style=\"text-align: center;\"><strong><a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-12-functions-part-1\/\">[Lesson 12]<\/a> &lt;&lt;<a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-tutorial\/\">[CONTENTS]<\/a> &gt;&gt;<a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-14-functions-part-iii-math-functions\/\"> [Lesson 14]<\/a><\/strong><\/h4>\n","protected":false},"excerpt":{"rendered":"<p>[Lesson 12] &lt;&lt;\u00a0[CONTENTS] &gt;&gt; [Lesson 14] There are many built-in functions In Visual Basic 2012. In this lesson, you\u00a0will learn a couple of built-in functions that deal with string manipulation. 13.1 The Mid Function The Mid function is used to retrieve a part of the text from a given phrase. The syntax of the Mid &hellip; <a href=\"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-13-function-part-ii\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Visual Basic 2012 Lesson 13- The Built-In Functions<\/span><\/a><\/p>\n","protected":false},"author":23013,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-2383","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Visual Basic 2012 Lesson 13- The Built-In Functions - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB<\/title>\n<meta name=\"description\" content=\"This visual basic 2012 tutorial shows how to use the built-in functions in visual basic 2012\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson13.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Visual Basic 2012 Lesson 13- The Built-In Functions - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB\" \/>\n<meta property=\"og:description\" content=\"This visual basic 2012 tutorial shows how to use the built-in functions in visual basic 2012\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson13.html\" \/>\n<meta property=\"og:site_name\" content=\"Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Vbtutor\" \/>\n<meta property=\"article:modified_time\" content=\"2018-06-24T10:01:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_13_1.gif\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@liewvk\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-13-function-part-ii\/\",\"url\":\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson13.html\",\"name\":\"Visual Basic 2012 Lesson 13- The Built-In Functions - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB\",\"isPartOf\":{\"@id\":\"https:\/\/www.vbtutor.net\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson13.html#primaryimage\"},\"image\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson13.html#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_13_1.gif\",\"datePublished\":\"2013-02-13T04:18:13+00:00\",\"dateModified\":\"2018-06-24T10:01:01+00:00\",\"description\":\"This visual basic 2012 tutorial shows how to use the built-in functions in visual basic 2012\",\"breadcrumb\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson13.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson13.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson13.html#primaryimage\",\"url\":\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_13_1.gif\",\"contentUrl\":\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_13_1.gif\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson13.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vbtutor.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Visual Basic 2012 Lesson 13- The Built-In Functions\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vbtutor.net\/#website\",\"url\":\"https:\/\/www.vbtutor.net\/\",\"name\":\"Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB\",\"description\":\"Start learning Visual Basic from beginner to advanced. Includes VB.NET, VBA, and classic VB tutorials for students and professionals.\",\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Visual Basic 2012 Lesson 13- The Built-In Functions - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","description":"This visual basic 2012 tutorial shows how to use the built-in functions in visual basic 2012","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":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson13.html","og_locale":"en_US","og_type":"article","og_title":"Visual Basic 2012 Lesson 13- The Built-In Functions - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","og_description":"This visual basic 2012 tutorial shows how to use the built-in functions in visual basic 2012","og_url":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson13.html","og_site_name":"Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","article_publisher":"https:\/\/www.facebook.com\/Vbtutor","article_modified_time":"2018-06-24T10:01:01+00:00","og_image":[{"url":"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_13_1.gif","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_site":"@liewvk","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-13-function-part-ii\/","url":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson13.html","name":"Visual Basic 2012 Lesson 13- The Built-In Functions - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","isPartOf":{"@id":"https:\/\/www.vbtutor.net\/#website"},"primaryImageOfPage":{"@id":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson13.html#primaryimage"},"image":{"@id":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson13.html#primaryimage"},"thumbnailUrl":"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_13_1.gif","datePublished":"2013-02-13T04:18:13+00:00","dateModified":"2018-06-24T10:01:01+00:00","description":"This visual basic 2012 tutorial shows how to use the built-in functions in visual basic 2012","breadcrumb":{"@id":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson13.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson13.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson13.html#primaryimage","url":"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_13_1.gif","contentUrl":"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_13_1.gif"},{"@type":"BreadcrumbList","@id":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson13.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vbtutor.net\/"},{"@type":"ListItem","position":2,"name":"Visual Basic 2012 Lesson 13- The Built-In Functions"}]},{"@type":"WebSite","@id":"https:\/\/www.vbtutor.net\/#website","url":"https:\/\/www.vbtutor.net\/","name":"Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","description":"Start learning Visual Basic from beginner to advanced. Includes VB.NET, VBA, and classic VB tutorials for students and professionals.","inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages\/2383","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/users\/23013"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/comments?post=2383"}],"version-history":[{"count":42,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages\/2383\/revisions"}],"predecessor-version":[{"id":13103,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages\/2383\/revisions\/13103"}],"wp:attachment":[{"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/media?parent=2383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/categories?post=2383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/tags?post=2383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}