{"id":1097,"date":"2012-04-06T16:43:10","date_gmt":"2012-04-06T08:43:10","guid":{"rendered":"http:\/\/www.vbtutor.net\/index.php\/"},"modified":"2018-06-24T18:05:07","modified_gmt":"2018-06-24T10:05:07","slug":"visual-basic-2010-lesson-15","status":"publish","type":"page","link":"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-lesson-15\/","title":{"rendered":"Visual Basic 2010 Lesson 15 &#8211; The Format Function"},"content":{"rendered":"<h4 align=\"center\"><strong><a href=\"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-lesson-14\/\">[Lesson 14]<\/a> <\/strong>&lt;&lt;\u00a0<strong><a href=\"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-tutorial\/\">[CONTENTS]<\/a> &gt;&gt;<a href=\"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-lesson-16\/\"> [Lesson 16]<\/a><\/strong><\/h4>\n<p>The Format function in Visual Basic 2010 displays the numeric values in different forms. There are two types of Format functions in Visual Basic 2010, one of them is the built-in format function while another one is defined by the users.<\/p>\n<p>(i) The syntax of a built-in Format function is as follows :<\/p>\n<pre style=\"font-size: 110%; width: 80%;\">Format (n, \"style argument\")<\/pre>\n<p>*\u00a0n is a number. The list of style arguments is given in Table 15.1.<\/p>\n<p><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br \/>\n<ins class=\"adsbygoogle\"\n     style=\"display:block; text-align:center;\"\n     data-ad-layout=\"in-article\"\n     data-ad-format=\"fluid\"\n     data-ad-client=\"ca-pub-3033628290023372\"\n     data-ad-slot=\"1723562988\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><br \/>\n<strong>Table 15.1 List of style arguments<\/strong><\/p>\n<div style=\"overflow-x:auto;\">\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<\/div>\n<p><strong>Example 15.1<\/strong><\/p>\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 is shown in Figure 15.1.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/www.vbtutor.net\/vb2008\/Images\/vb2008_15_1.gif\" alt=\"Visual Basic 2010\" width=\"300\" height=\"300\" \/><\/p>\n<h4 align=\"center\">Figure 15.1<\/h4>\n<p><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br \/>\n<ins class=\"adsbygoogle\"\n     style=\"display:block; text-align:center;\"\n     data-ad-layout=\"in-article\"\n     data-ad-format=\"fluid\"\n     data-ad-client=\"ca-pub-3033628290023372\"\n     data-ad-slot=\"1723562988\"><\/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 2010\" 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 in Figure 15.2.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft\" src=\"https:\/\/www.vbtutor.net\/vb2008\/Images\/vb2008_15_2.gif\" alt=\"Visual Basic 2010\" width=\"300\" height=\"300\" \/><\/p>\n<h4>Figure 15.2<\/h4>\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=\"8075128701\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><\/p>\n<h4 align=\"center\"><strong><a href=\"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-lesson-14\/\">[Lesson 14]<\/a> <a href=\"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-tutorial\/\">[CONTENTS]<\/a> &gt;&gt;<a href=\"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-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 2010 displays the numeric values in different forms. There are two types of Format functions in Visual Basic 2010, one of them is the built-in format function while another one is defined by the users. (i) The syntax of a built-in Format function &hellip; <a href=\"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-lesson-15\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Visual Basic 2010 Lesson 15 &#8211; 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-1097","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 2010 Lesson 15 - The Format Function - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB<\/title>\n<meta name=\"description\" content=\"This Visual Basic 2010 lesson shows you how to use format functions in Visual Basic 2010\" \/>\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\/vb2010\/vb2010_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 2010 Lesson 15 - The Format Function - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB\" \/>\n<meta property=\"og:description\" content=\"This Visual Basic 2010 lesson shows you how to use format functions in Visual Basic 2010\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_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:05:07+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-2010-lesson-15\/\",\"url\":\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson15.html\",\"name\":\"Visual Basic 2010 Lesson 15 - 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\/vb2010\/vb2010_lesson15.html#primaryimage\"},\"image\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson15.html#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.vbtutor.net\/vb2008\/Images\/vb2008_15_1.gif\",\"datePublished\":\"2012-04-06T08:43:10+00:00\",\"dateModified\":\"2018-06-24T10:05:07+00:00\",\"description\":\"This Visual Basic 2010 lesson shows you how to use format functions in Visual Basic 2010\",\"breadcrumb\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson15.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson15.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_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\/vb2010\/vb2010_lesson15.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vbtutor.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Visual Basic 2010 Lesson 15 &#8211; 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 2010 Lesson 15 - The Format Function - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","description":"This Visual Basic 2010 lesson shows you how to use format functions in Visual Basic 2010","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\/vb2010\/vb2010_lesson15.html","og_locale":"en_US","og_type":"article","og_title":"Visual Basic 2010 Lesson 15 - The Format Function - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","og_description":"This Visual Basic 2010 lesson shows you how to use format functions in Visual Basic 2010","og_url":"http:\/\/www.vbtutor.net\/vb2010\/vb2010_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:05:07+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-2010-lesson-15\/","url":"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson15.html","name":"Visual Basic 2010 Lesson 15 - 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\/vb2010\/vb2010_lesson15.html#primaryimage"},"image":{"@id":"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson15.html#primaryimage"},"thumbnailUrl":"https:\/\/www.vbtutor.net\/vb2008\/Images\/vb2008_15_1.gif","datePublished":"2012-04-06T08:43:10+00:00","dateModified":"2018-06-24T10:05:07+00:00","description":"This Visual Basic 2010 lesson shows you how to use format functions in Visual Basic 2010","breadcrumb":{"@id":"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson15.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson15.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.vbtutor.net\/vb2010\/vb2010_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\/vb2010\/vb2010_lesson15.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vbtutor.net\/"},{"@type":"ListItem","position":2,"name":"Visual Basic 2010 Lesson 15 &#8211; 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\/1097","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=1097"}],"version-history":[{"count":51,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages\/1097\/revisions"}],"predecessor-version":[{"id":13105,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages\/1097\/revisions\/13105"}],"wp:attachment":[{"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/media?parent=1097"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/categories?post=1097"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/tags?post=1097"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}