{"id":5075,"date":"2014-03-30T18:39:55","date_gmt":"2014-03-30T18:39:55","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/visual-basic-net-rounding-issue-collection-of-common-programming-errors\/"},"modified":"2014-03-30T18:39:55","modified_gmt":"2014-03-30T18:39:55","slug":"visual-basic-net-rounding-issue-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/visual-basic-net-rounding-issue-collection-of-common-programming-errors\/","title":{"rendered":"Visual Basic .Net Rounding Issue-Collection of common programming errors"},"content":{"rendered":"<p>I am building a unit converter with Visual Basic and Visual Studio 2012. I am using the conversion rate of 1 inch = 0.0833333 feet for the inch to foot conversion. When I type in 12 inches, it gives me an answer of 0.9999996 instead of 1. How can I fix this problem?<\/p>\n<p>The issue is with the inch to foot conversion below.<\/p>\n<pre><code>            ' converts inch to...\n            If cbo1.SelectedIndex = 3 Then\n                If cbo2.SelectedIndex = 0 Then\n                    ' meter\n                    txtUnit2.Text = (dblUnit1 * 0.0254).ToString.Trim\n                ElseIf cbo2.SelectedIndex = 1 Then\n                    ' millimeter\n                    txtUnit2.Text = (dblUnit1 * 25.4).ToString.Trim\n                ElseIf cbo2.SelectedIndex = 2 Then\n                    ' foot\n                    txtUnit2.Text = (dblUnit1 * 0.0833333).ToString.Trim\n                ElseIf cbo2.SelectedIndex = 3 Then\n                    ' inch\n                    txtUnit2.Text = txtUnit1.Text\n                End If\n            End If\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I am building a unit converter with Visual Basic and Visual Studio 2012. I am using the conversion rate of 1 inch = 0.0833333 feet for the inch to foot conversion. When I type in 12 inches, it gives me an answer of 0.9999996 instead of 1. How can I fix this problem? The issue [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5075","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5075","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5075"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5075\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5075"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5075"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5075"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}