|
-
Jul 28th, 2004, 09:02 AM
#1
Thread Starter
New Member
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
-
Jul 28th, 2004, 10:49 AM
#2
VB Code:
Dim dblOne As Double
Dim dblTwo As Double
Dim dblBig As Double
dblOne = CDbl(TextBox1.Text)
dblTwo = CDbl(TextBox2.Text)
dblBig = IIf(dblOne > dblTwo, dblOne, dblTwo)
MessageBox.Show("The bigger number is " & dblBig.ToString & " :)")
-
Jul 28th, 2004, 10:52 AM
#3
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.
-
Jul 28th, 2004, 04:19 PM
#4
Thread Starter
New Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|