Page 133 - Open Soource Technologies 304.indd
P. 133

Unit 6: VB Control Structure



               and each action consists of a single assignment statement. With the inputs 3 and 7, the condition
               is false, and so the second action is taken.























                             Object             Property        Setting
                             FrmMaximum         Text            Maximum
                             LblFirstNum        Text            First Number:
                             TxtFirstNum

                             LblSecondNum       Text            Second Number:
                             TxtSecondNum
                             BtnFindLarger      Text            Find  Larger Number
                             TxtResult          ReadOnly        True

               Private Sub btnFindLarger_Click(...) Handles btnFindLarger.Click
                 Dim num1, num2, largerNum As Double
                 num1 = CDbl (txtFirstNum.Text)
                 num2 = CDbl (txtSecondNum.Text)
                 If num1 > num2 Then
                   largerNum = num1
                 Else
                   largerNum = num2
                 EndIf
                 txtResult.Text = “The larger number is “ & largerNum
               End Sub
               [Run, type 3 and 7 into the text boxes, and press the button.]








                                      LOVELY PROFESSIONAL UNIVERSITY                        127
   128   129   130   131   132   133   134   135   136   137   138