I need to write an application that allows the user to enter three Double values, then determines and
displays the smallest and largest values.
Using functions to get s Minimum and Maximum that each receive three Double values and return a Double result and by using the math.min math.max.
I also need to do input verification so only numbers can be entered and not a string.
What am I doing wrong now!!!????
I am not getting the validation to work... where is my error??
displays the smallest and largest values.
Using functions to get s Minimum and Maximum that each receive three Double values and return a Double result and by using the math.min math.max.
I also need to do input verification so only numbers can be entered and not a string.
What am I doing wrong now!!!????
vb Code:
Option Strict On Public Class HighestLowest ' code pseoudo ' INPUT 3 numbers ' pass to function lowest ' return lowest DISPLAY lowest ' pass to function highest ' return highest DISPLAY highest ' global vars Dim oneNum As Double = 0 Dim twoNum As Double = 0 Dim threeNum As Double = 0 Dim highNum As Double Dim lowNum As Double Private Sub submitBtn_Click(sender As Object, e As EventArgs) Handles submitBtn.Click ' verify that the input is a number If IsNumeric(input1Tbx.Text) = True Then oneNum = CDbl(input1Tbx.Text) ElseIf : MessageBox.Show("Please enter numbers only.", "Please check your input values.", MessageBoxButtons.OK, MessageBoxIcon.Error) input1Tbx.Text = "" input2Tbx.Text = "" input3Tbx.Text = "" input1Tbx.Focus() Exit Sub If IsNumeric(input2Tbx.Text) = True Then twoNum = CDbl(input2Tbx.Text) ElseIf : MessageBox.Show("Please enter numbers only.", "Please check your input values.", MessageBoxButtons.OK, MessageBoxIcon.Error) input1Tbx.Text = "" input2Tbx.Text = "" input3Tbx.Text = "" input1Tbx.Focus() Exit Sub If IsNumeric(input3Tbx.Text) = True Then threeNum = CDbl(input3Tbx.Text) ElseIf : MessageBox.Show("Please enter numbers only.", "Please check your input values.", MessageBoxButtons.OK, MessageBoxIcon.Error) input1Tbx.Text = "" input2Tbx.Text = "" input3Tbx.Text = "" input1Tbx.Focus() Exit Sub End If End If End If highNum = largest(oneNum, twoNum, threeNum) largestLbl.Text = highNum.ToString lowNum = smallest(oneNum, twoNum, threeNum) smallestLbl.Text = lowNum.ToString End Sub Function largest(ByVal one As Double, ByVal two As Double, ByVal three As Double) As Double Dim tempMax As Double Dim finalMax As Double tempMax = Math.Max(one, two) finalMax = Math.Max(tempMax, three) Return finalMax End Function ' Maximum Function smallest(ByVal one As Double, ByVal two As Double, ByVal three As Double) As Double Dim tempMin As Double Dim finalMin As Double tempMin = Math.Min(one, two) finalMin = Math.Min(tempMin, three) Return finalMin End Function ' Minimum End Class
I am not getting the validation to work... where is my error??