{"id":3767,"date":"2021-11-04T22:03:05","date_gmt":"2021-11-04T22:03:05","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=3767"},"modified":"2021-11-04T22:04:00","modified_gmt":"2021-11-04T22:04:00","slug":"finding-the-larger-of-2-numbers-visual-basic","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/finding-the-larger-of-2-numbersvisual-basic\/23185.html","title":{"rendered":"Finding The Larger Of 2 Numbers-VISUAL BASIC"},"content":{"rendered":"<p>Hello, I&#8217;m trying to write a code which would allow me to write 2 random numbers and then show the larger number when clicked on a button called &#8220;Display Largest&#8221;, below you can see my code which I have written. If anyone is able to fix it for me &#8211; please do, thank you:<\/p>\n<p>Public Class Form1<br \/>\nDim First As Integer<br \/>\nDim Second As Integer<\/p>\n<p>Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLargest.Click<br \/>\nFirst = Val(txtFirst.Text)<br \/>\nSecond = Val(txtSecond.Text)<br \/>\nIf First &gt; Second Then<br \/>\nbtnLargest = First &#8216;Confused as to what write in here :\/<br \/>\nMessageBox.Show(&#8220;txtFirst.text&#8221;)<br \/>\nElse<br \/>\ntxtLargest = txtSecond &#8216;Please help me with this part as well<br \/>\nMessageBox.Show(&#8220;txtSecond&#8221;)<br \/>\n&#8216;Basically I want to see the larger number when clicked on &#8220;btnLargest&#8221; (Button1_Click)<br \/>\n&#8216;I&#8217;m clearly having some problems with &#8220;IF&#8221; and &#8220;ELSE&#8221; functions.<\/p>\n<p>End If<br \/>\nEnd Sub<\/p>\n<p>Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click<br \/>\nMe.Close()<\/p>\n<p>End Sub<\/p>\n<p>Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click<br \/>\ntxtFirst.Clear()<br \/>\ntxtSecond.Clear()<br \/>\ntxtLargest.Clear()<\/p>\n<p>End Sub<\/p>\n<p>Private Sub txtbox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtFirst.TextChanged<\/p>\n<p>End Sub<\/p>\n<p>Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<\/p>\n<p>End Sub<\/p>\n<p>Private Sub txtLargest_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtLargest.TextChanged<\/p>\n<p>End Sub<br \/>\nEnd Class<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":1},"question-category":[55],"question_tags":[],"class_list":["post-3767","question","type-question","status-publish","hentry","question-category-programming"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/3767","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=3767"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=3767"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=3767"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=3767"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}