{"id":2455,"date":"2013-02-13T14:01:21","date_gmt":"2013-02-13T06:01:21","guid":{"rendered":"http:\/\/www.vbtutor.net\/index.php\/"},"modified":"2018-06-24T18:06:55","modified_gmt":"2018-06-24T10:06:55","slug":"visual-basic-2012-lesson-15","status":"publish","type":"page","link":"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-15\/","title":{"rendered":"Visual Basic 2012 Lesson 15\u2013 The Format Function"},"content":{"rendered":"<h4 align=\"center\"><strong><a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-14-functions-part-iii-math-functions\/\">[Lesson 14]<\/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-16\/\"> [Lesson 16]<\/a><\/strong><\/h4>\n<p>The Format function in Visual Basic 2012 is to display the numbers in different formats. There are two types of Format functions, one of them is the built-in format function and the other one is defined by the users.<\/p>\n<p>(i) The syntax of the predefined Format function is<\/p>\n<pre style=\"font-size: 110%; width: 80%;\">Format (n, \"style argument\")<\/pre>\n<p>where n is a number.<\/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><br \/>\nThe list of style arguments in Visual Basic 2012 is given in Table 15.1.<\/p>\n<h4><strong>Table 15.1 List of style arguments<\/strong><\/h4>\n<table>\n<tbody>\n<tr>\n<th><strong>Style argument<\/strong><\/th>\n<th><strong>Explanation<\/strong><\/th>\n<th><strong>Example<\/strong><\/th>\n<\/tr>\n<tr>\n<td>General Number<\/td>\n<td>To display the number without having separators between thousands.<\/td>\n<td>Format(8972.234, &#8220;General Number&#8221;)=8972.234<\/td>\n<\/tr>\n<tr>\n<td>Fixed<\/td>\n<td>To display the number without having separators between thousands and rounds it up to two decimal places.<\/td>\n<td>Format(8972.2, &#8220;Fixed&#8221;)=8972.23<\/td>\n<\/tr>\n<tr>\n<td>Standard<\/td>\n<td>To display the number with separators or separators between thousands and rounds it up to two decimal places.<\/td>\n<td>Format(6648972.265, &#8220;Standard&#8221;)= 6,648,972.27<\/td>\n<\/tr>\n<tr>\n<td>Currency<\/td>\n<td>To display the number with the dollar sign in front has separators between thousands as well as rounding it up to two decimal places.<\/td>\n<td>Format(6648972.265, &#8220;Currency&#8221;)= $6,648,972.27<\/td>\n<\/tr>\n<tr>\n<td>Percent<\/td>\n<td>Converts the number to the percentage form and displays a % sign and rounds it up to two decimal places.<\/td>\n<td>Format(0.56324, &#8220;Percent&#8221;)=56.32 %<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Example 15.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, Button5.Click, Button4.Click, Button3.Click\r\n Label1.Text = Format(8972.234, \"General Number\")\r\n Label2.Text = Format(8972.2, \"Fixed\")\r\n Label3.Text = Format(6648972.265, \"Standard\")\r\n Label4.Text = Format(6648972.265, \"Currency\")\r\n Label5.Text = Format(0.56324, \"Percent\")\r\nEnd Sub\r\n<\/pre>\n<p>The Output window is shown below:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/www.vbtutor.net\/vb2008\/Images\/vb2008_15_1.gif\" alt=\"Visual Basic 2012\" width=\"300\" height=\"300\" \/><br \/>\n<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><br \/>\n(ii) The syntax of the user-defined Format function is<\/p>\n<pre style=\"font-size: 110%; width: 70%;\">Format (n, \"user's format\")<\/pre>\n<p>Although it is known as user-defined format, we still need to follow certain formatting styles. Examples of user-defined formatting style are listed in Table 15.2<\/p>\n<p><a href=\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2012\/04\/table15.21.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1278\" title=\"table15.2\" src=\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2012\/04\/table15.21.jpg\" alt=\"Visual Basic 2012\" width=\"665\" height=\"348\" srcset=\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2012\/04\/table15.21.jpg 665w, https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2012\/04\/table15.21-300x156.jpg 300w\" sizes=\"auto, (max-width: 665px) 100vw, 665px\" \/><\/a><\/p>\n<h4>Example 15.2<\/h4>\n<pre style=\"font-size: 110%;\">Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button5.Click, Button4.Click, Button3.Click\r\n Label1.Text = Format(8972.234, \"0.0\")\r\n Label2.Text = Format(8972.2345, \"0.00\")\r\n Label3.Text = Format(6648972.265, \"#,##0.00\")\r\n Label4.Text = Format(6648972.265, \"$#,##0.00\")\r\n Label5.Text = Format(0.56324, \"0%\")\r\nEnd Sub\r\n<\/pre>\n<p>The Output window is shown below:<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.vbtutor.net\/vb2008\/Images\/vb2008_15_2.gif\" alt=\"\" width=\"300\" height=\"300\" \/><\/p>\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-14-functions-part-iii-math-functions\/\">[Lesson 14]<\/a> <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-16\/\"> [Lesson 16]<\/a><\/strong><\/h4>\n","protected":false},"excerpt":{"rendered":"<p>[Lesson 14] &lt;&lt;\u00a0[CONTENTS] &gt;&gt; [Lesson 16] The Format function in Visual Basic 2012 is to display the numbers in different formats. There are two types of Format functions, one of them is the built-in format function and the other one is defined by the users. (i) The syntax of the predefined Format function is Format &hellip; <a href=\"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-15\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Visual Basic 2012 Lesson 15\u2013 The Format Function<\/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-2455","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 15\u2013 The Format Function - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB<\/title>\n<meta name=\"description\" content=\"This visual basic 2012 tutorial illustrates the use of the Format 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_lesson15.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 15\u2013 The Format Function - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB\" \/>\n<meta property=\"og:description\" content=\"This visual basic 2012 tutorial illustrates the use of the Format Functions in Visual Basic 2012\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson15.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:06:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.vbtutor.net\/vb2008\/Images\/vb2008_15_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=\"2 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-15\/\",\"url\":\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson15.html\",\"name\":\"Visual Basic 2012 Lesson 15\u2013 The Format Function - 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_lesson15.html#primaryimage\"},\"image\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson15.html#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.vbtutor.net\/vb2008\/Images\/vb2008_15_1.gif\",\"datePublished\":\"2013-02-13T06:01:21+00:00\",\"dateModified\":\"2018-06-24T10:06:55+00:00\",\"description\":\"This visual basic 2012 tutorial illustrates the use of the Format Functions in Visual Basic 2012\",\"breadcrumb\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson15.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson15.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson15.html#primaryimage\",\"url\":\"https:\/\/www.vbtutor.net\/vb2008\/Images\/vb2008_15_1.gif\",\"contentUrl\":\"https:\/\/www.vbtutor.net\/vb2008\/Images\/vb2008_15_1.gif\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson15.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vbtutor.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Visual Basic 2012 Lesson 15\u2013 The Format Function\"}]},{\"@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 15\u2013 The Format Function - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","description":"This visual basic 2012 tutorial illustrates the use of the Format 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_lesson15.html","og_locale":"en_US","og_type":"article","og_title":"Visual Basic 2012 Lesson 15\u2013 The Format Function - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","og_description":"This visual basic 2012 tutorial illustrates the use of the Format Functions in Visual Basic 2012","og_url":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson15.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:06:55+00:00","og_image":[{"url":"https:\/\/www.vbtutor.net\/vb2008\/Images\/vb2008_15_1.gif","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_site":"@liewvk","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-15\/","url":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson15.html","name":"Visual Basic 2012 Lesson 15\u2013 The Format Function - 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_lesson15.html#primaryimage"},"image":{"@id":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson15.html#primaryimage"},"thumbnailUrl":"https:\/\/www.vbtutor.net\/vb2008\/Images\/vb2008_15_1.gif","datePublished":"2013-02-13T06:01:21+00:00","dateModified":"2018-06-24T10:06:55+00:00","description":"This visual basic 2012 tutorial illustrates the use of the Format Functions in Visual Basic 2012","breadcrumb":{"@id":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson15.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson15.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson15.html#primaryimage","url":"https:\/\/www.vbtutor.net\/vb2008\/Images\/vb2008_15_1.gif","contentUrl":"https:\/\/www.vbtutor.net\/vb2008\/Images\/vb2008_15_1.gif"},{"@type":"BreadcrumbList","@id":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_lesson15.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vbtutor.net\/"},{"@type":"ListItem","position":2,"name":"Visual Basic 2012 Lesson 15\u2013 The Format Function"}]},{"@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\/2455","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=2455"}],"version-history":[{"count":39,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages\/2455\/revisions"}],"predecessor-version":[{"id":13106,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages\/2455\/revisions\/13106"}],"wp:attachment":[{"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/media?parent=2455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/categories?post=2455"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/tags?post=2455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}