Results 1 to 4 of 4

Thread: need some help

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    2

    Angry need some help

    I have been trying this over and over and over again. I am trying to write code to "find the larger of two numbers". Could anyone help me on this? Here is what I have so far. Thanks to all in advance :-)

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    'Find the larger of two numbers input by the user'.

    Dim num1, num2, largerNum As Double
    Dim txtFirstNum, txtSecondNum, txtResults
    num1 = CDbl(txtFirstNum.Text)
    num2 = CDbl(txtSecondNum.Text)
    If num1 > num2 Then
    largerNum = num1
    Else
    largerNum = num2
    End If
    txtResults.Text = "The larger number is " & largerNum
    End Sub
    End Class

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    VB Code:
    1. Dim dblOne As Double
    2.         Dim dblTwo As Double
    3.         Dim dblBig As Double
    4.  
    5.         dblOne = CDbl(TextBox1.Text)
    6.         dblTwo = CDbl(TextBox2.Text)
    7.  
    8.         dblBig = IIf(dblOne > dblTwo, dblOne, dblTwo)
    9.  
    10.         MessageBox.Show("The bigger number is " & dblBig.ToString & " :)")

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Note that there, I've assumed that one number will always be bigger than the other.

    In case they're equal, the answer won't matter, since they're essentially the same.

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    2
    Thank you for the help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width