Getting the largest and smallest Values - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Getting the largest and smallest Values

allan1392allan1392 Posts: 1Member
My problem is I have a program that needs to input 3 values in 1 textbox only. I've been trying to figure that out for a couple of days now.

this program must show the largest, smallest and average of 3 values.

So far, this is what i've got, I don't know what is wrong with this.
If anyone can help me, it would be greatly appreciated.

[code]Public Class Form2
Dim array() As Integer = New Integer() {a, b, c}
Dim a, b, c As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
array(0) = a
array(1) = b
array(2) = c

For i = 0 To 3
array(0) = Me.TextBox1.Text
array(1) = Me.TextBox1.Text
array(2) = Me.TextBox1.Text
Next

Label1.Text = larg(a, b, c)
Label2.Text = small(a, b, c)
Label3.Text = average(a, b, c)

TextBox1.Clear()
End Sub

Function larg(ByVal x As Integer, ByVal y As Integer, ByVal z As Integer) As Integer
If x > y Then
Return x
ElseIf y > z Then
Return y
Else
Return z
End If
End Function

Function small(ByVal x As Integer, ByVal y As Integer, ByVal z As Integer) As Integer
If x < y Then
Return x
ElseIf y < z Then
Return y
Else
Return z
End If
End Function

Function average(ByVal x As Integer, ByVal y As Integer, ByVal z As Integer) As Integer
Return (x + y + z) / 3
End Function
End Class[/code]
Sign In or Register to comment.