{"id":4447,"date":"2014-01-10T16:13:54","date_gmt":"2014-01-10T08:13:54","guid":{"rendered":"http:\/\/www.vbtutor.net\/?page_id=4447"},"modified":"2018-06-24T16:40:06","modified_gmt":"2018-06-24T08:40:06","slug":"vb2013-lesson-11-performing-mathematical-operations","status":"publish","type":"page","link":"https:\/\/www.vbtutor.net\/index.php\/vb2013-lesson-11-performing-mathematical-operations\/","title":{"rendered":"Visual Basic 2013 Lesson 11: Managing Mathematical Operations"},"content":{"rendered":"<h4 style=\"text-align: center;\"><a href=\"http:\/\/www.vbtutor.net\/index.php\/vb2013-lesson-10-arrays\/\">[Lesson 10] <\/a>&lt;&lt; <a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2013-tutorial\/\">[Contents]<\/a> &gt;&gt; <a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2013-lesson-12-string-manipulation\/\">[Lesson 12]<\/a><\/h4>\n<p>Basically, mathematical operations form an integral part of computer programming. Indeed, we can write Visual Basic 2013 code to instruct the computer to perform mathematical calculations. Furthermore, we can create VB applications that are able to solve complex mathematical problems.<\/p>\n<p>For example, we can develop VB applications like<a href=\"https:\/\/www.vbtutor.net\/VB_Sample\/simuleq.htm\">\u00a0simultaneous equations Solver<\/a>\u00a0and <a href=\"https:\/\/www.vbtutor.net\/VB_Sample\/factors%20Finders.html\">Factors Finder<\/a>. Besides that, we can use mathematical operations to create programs like the <a href=\"https:\/\/www.vbtutor.net\/VB_Sample\/vbslot2.htm\">slot machine<\/a>, <a href=\"https:\/\/www.vbtutor.net\/VB_Sample\/starwar.htm\">star war<\/a>, <a href=\"https:\/\/www.vbtutor.net\/VB_Sample\/amortize.htm\">amortization calculators<\/a> and so on. In order to write a VB program that involves mathematical operations, we need to use the standard arithmetic\u00a0operators. In addition, we must also use some mathematical formulas as well as equations.<\/p>\n<p>The Visual Basic 2013 mathematical\u00a0operators are very similar to the normal arithmetic operators, only with some slight variations. The list of VB 2013 mathematical\u00a0operators are shown in table 11.1 below:<\/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=\"3914691604\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><\/p>\n<h4 align=\"center\">Table 11.1: Mathematical Operators<\/h4>\n<div style=\"overflow-x:auto;\">\n<table>\n<tbody>\n<tr>\n<th style=\"text-align:center; width:20%\">Operator<\/th>\n<th>Mathematical Function<\/th>\n<th>Example<\/th>\n<\/tr>\n<tr>\n<td>+<\/td>\n<td>Addition<\/td>\n<td>\u00a01+2=3<\/td>\n<\/tr>\n<tr>\n<td>&#8211;<\/td>\n<td>\u00a0Subtraction<\/td>\n<td>\u00a010-4=6<\/td>\n<\/tr>\n<tr>\n<td>^<\/td>\n<td>\u00a0Exponential<\/td>\n<td>\u00a03^2=9<\/td>\n<\/tr>\n<tr>\n<td>*<\/td>\n<td>\u00a0Multiplication<\/td>\n<td>\u00a05*6=30<\/td>\n<\/tr>\n<tr>\n<td>\/<\/td>\n<td>\u00a0Division<\/td>\n<td>\u00a021\/7=3<\/td>\n<\/tr>\n<tr>\n<td>Mod<\/td>\n<td>\u00a0Modulus(returns the remainder of an integer division)<\/td>\n<td>\u00a015 Mod 4=3<\/td>\n<\/tr>\n<tr>\n<td>\\<\/td>\n<td>\u00a0Integer Division(discards the decimal places)<\/td>\n<td>\u00a019\/4=4<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h4><strong>Example 11.1<\/strong><\/h4>\n<p>In this example, we\u00a0insert two text boxes, four labels, and a\u00a0button. Now, click the button and enter the code as shown below. When you run the program, it will perform\u00a0four basic arithmetic operations and displays the results on the four labels.<\/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 num1, num2, difference, product, quotient As Single\r\n num1 = TextBox1.Text\r\n num2 = TextBox2.Text\r\n sum=num1+num2\r\n difference=num1-num2\r\n product = num1 * num2\r\n quotient=num1\/num2\r\n Label1.Text=sum\r\n Label2.Text=difference\r\n Label3.Text = product\r\n Label4.Text = quotient\r\nEnd Sub<\/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=\"3914691604\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><\/p>\n<h4>Example 11.2<\/h4>\n<p>This program employs the Pythagoras Theorem to calculate the length of hypotenuse c given the length of the adjacent side a and the opposite side b. For those of\u00a0\u00a0you who have forgotten the formula for the Pythagoras Theorem, it is written as<\/p>\n<pre style=\"font-size: 110%;\">c^2=a^2+b^2\r\n<\/pre>\n<h4>The Code<\/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 a, b, c As Single\r\n a = TextBox1.Text\r\n b = TextBox2.Text\r\n c=(a^2+b^2)^(1\/2)\r\n Label3.Text=c\r\nEnd Sub\r\n<\/pre>\n<h4><strong>Example 11.3: BMI Calculator<\/strong><\/h4>\n<p>In today&#8217;s world, many people are obese and it could affect their health seriously. In fact, obesity has proven by the medical experts to be one of the main factors that bring many adverse medical problems, including the cardiovascular disease. Based on scientific research, if your BMI is more than 30, you are considered obese. You can refer to the following range of BMI values for your weight status.<\/p>\n<p>Underweight = &lt;18.5<br \/>\nNormal weight = 18.5-24.9<br \/>\nOverweight = 25-29.9<br \/>\nObesity = BMI of 30 or greater<\/p>\n<p>To\u00a0calculate your BMI, it is not necessary to consult a doctor, you can simply\u00a0use a calculator or a DIY\u00a0computer program instead. In this example, we will show you how to create a BMI calculator. The BMI value can be calculated using the formula weight\/( height )^2, where weight is measured in kg and height in meter. If you only know your weight and height in lb and feet, then you need to convert them to the metric system.<\/p>\n<pre style=\"font-size: 110%;\">Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArsgs) Handles Button1.Click\r\nDim height, weight, bmi As Single\r\n height = TextBox1.Text\r\n weight = TextBox2.Text\r\n bmi = (weight) \/ (height ^ 2)\r\n Label4.Text = bmi\r\nEnd Sub\r\n<\/pre>\n<p>The output is shown in the Figure 11.1 below. In this example, your height is 1.80m( about 5 foot 11),your weight is 75 kg( about 168Ib), and your BMI is about 23.14815. The reading suggests that you are healthy. (Note; 1 foot=0.3048, 1 lb=.45359237 kilogram)<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_7.1.gif\" alt=\"\" width=\"300\" height=\"300\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>From the above examples, you can see that writing visual basic 2013 code that involves arithmetic operations is relatively easy. Here are more projects you work on:<\/p>\n<p>Area of a triangle<br \/>\nArea of a rectangle<br \/>\nArea of a circle<br \/>\nVolume of a cylinder<br \/>\nVolume of a cone<br \/>\nVolume of a sphere<br \/>\nCompound interest<br \/>\nFuture value<br \/>\nMean<br \/>\nVariance<br \/>\nSum of angles in polygons<br \/>\nConversion of lb to kg<br \/>\nConversion of Fahrenheit to Celsius<br \/>\n<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=\"2306771905\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><\/p>\n<h4 style=\"text-align: center;\"><a href=\"http:\/\/www.vbtutor.net\/index.php\/vb2013-lesson-10-arrays\/\">[Lesson 10]\u00a0<\/a>&lt;&lt;\u00a0<a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2013-tutorial\/\">[Contents]<\/a>\u00a0&gt;&gt; <a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2013-lesson-12-string-manipulation\/\">[Lesson 12]<\/a><\/h4>\n","protected":false},"excerpt":{"rendered":"<p>[Lesson 10] &lt;&lt; [Contents] &gt;&gt; [Lesson 12] Basically, mathematical operations form an integral part of computer programming. Indeed, we can write Visual Basic 2013 code to instruct the computer to perform mathematical calculations. Furthermore, we can create VB applications that are able to solve complex mathematical problems. For example, we can develop VB applications like\u00a0simultaneous &hellip; <a href=\"https:\/\/www.vbtutor.net\/index.php\/vb2013-lesson-11-performing-mathematical-operations\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Visual Basic 2013 Lesson 11: Managing Mathematical Operations<\/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-4447","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 2013 Lesson 11: Managing Mathematical Operations - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB<\/title>\n<meta name=\"description\" content=\"This lesson discuss the usage of mathematical operators in visual basic 2013 to perform mathematical operations\" \/>\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\/vb2013\/vb2013_lesson11.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Visual Basic 2013 Lesson 11: Managing Mathematical Operations - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB\" \/>\n<meta property=\"og:description\" content=\"This lesson discuss the usage of mathematical operators in visual basic 2013 to perform mathematical operations\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.vbtutor.net\/vb2013\/vb2013_lesson11.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-24T08:40:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_7.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=\"3 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\/vb2013-lesson-11-performing-mathematical-operations\/\",\"url\":\"http:\/\/www.vbtutor.net\/vb2013\/vb2013_lesson11.html\",\"name\":\"Visual Basic 2013 Lesson 11: Managing Mathematical Operations - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB\",\"isPartOf\":{\"@id\":\"https:\/\/www.vbtutor.net\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2013\/vb2013_lesson11.html#primaryimage\"},\"image\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2013\/vb2013_lesson11.html#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_7.1.gif\",\"datePublished\":\"2014-01-10T08:13:54+00:00\",\"dateModified\":\"2018-06-24T08:40:06+00:00\",\"description\":\"This lesson discuss the usage of mathematical operators in visual basic 2013 to perform mathematical operations\",\"breadcrumb\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2013\/vb2013_lesson11.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.vbtutor.net\/vb2013\/vb2013_lesson11.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.vbtutor.net\/vb2013\/vb2013_lesson11.html#primaryimage\",\"url\":\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_7.1.gif\",\"contentUrl\":\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_7.1.gif\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.vbtutor.net\/vb2013\/vb2013_lesson11.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vbtutor.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Visual Basic 2013 Lesson 11: Managing Mathematical Operations\"}]},{\"@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 2013 Lesson 11: Managing Mathematical Operations - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","description":"This lesson discuss the usage of mathematical operators in visual basic 2013 to perform mathematical operations","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\/vb2013\/vb2013_lesson11.html","og_locale":"en_US","og_type":"article","og_title":"Visual Basic 2013 Lesson 11: Managing Mathematical Operations - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","og_description":"This lesson discuss the usage of mathematical operators in visual basic 2013 to perform mathematical operations","og_url":"http:\/\/www.vbtutor.net\/vb2013\/vb2013_lesson11.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-24T08:40:06+00:00","og_image":[{"url":"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_7.1.gif","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_site":"@liewvk","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vbtutor.net\/index.php\/vb2013-lesson-11-performing-mathematical-operations\/","url":"http:\/\/www.vbtutor.net\/vb2013\/vb2013_lesson11.html","name":"Visual Basic 2013 Lesson 11: Managing Mathematical Operations - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","isPartOf":{"@id":"https:\/\/www.vbtutor.net\/#website"},"primaryImageOfPage":{"@id":"http:\/\/www.vbtutor.net\/vb2013\/vb2013_lesson11.html#primaryimage"},"image":{"@id":"http:\/\/www.vbtutor.net\/vb2013\/vb2013_lesson11.html#primaryimage"},"thumbnailUrl":"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_7.1.gif","datePublished":"2014-01-10T08:13:54+00:00","dateModified":"2018-06-24T08:40:06+00:00","description":"This lesson discuss the usage of mathematical operators in visual basic 2013 to perform mathematical operations","breadcrumb":{"@id":"http:\/\/www.vbtutor.net\/vb2013\/vb2013_lesson11.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.vbtutor.net\/vb2013\/vb2013_lesson11.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.vbtutor.net\/vb2013\/vb2013_lesson11.html#primaryimage","url":"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_7.1.gif","contentUrl":"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_7.1.gif"},{"@type":"BreadcrumbList","@id":"http:\/\/www.vbtutor.net\/vb2013\/vb2013_lesson11.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vbtutor.net\/"},{"@type":"ListItem","position":2,"name":"Visual Basic 2013 Lesson 11: Managing Mathematical Operations"}]},{"@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\/4447","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=4447"}],"version-history":[{"count":78,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages\/4447\/revisions"}],"predecessor-version":[{"id":13066,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages\/4447\/revisions\/13066"}],"wp:attachment":[{"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/media?parent=4447"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/categories?post=4447"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/tags?post=4447"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}