label10 displays which is the highest number
label12 displays which is the lowest number
label14 displays which is the number that is duplicated

pls help my codes don't run 100% correct.:'(

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label6.Text = Val(TextBox1.Text)
        Label7.Text = Val(TextBox2.Text)
        Label8.Text = Val(TextBox3.Text)


        If Val(TextBox1.Text) > Val(TextBox2.Text) Then
            Label10.Text = TextBox1.Text
            Label12.Text = TextBox2.Text
        ElseIf Val(TextBox2.Text) > Val(TextBox1.Text) Then
            Label10.Text = TextBox2.Text
            Label12.Text = TextBox1.Text
        ElseIf Val(TextBox3.Text) > Val(TextBox1.Text) Then
            Label10.Text = TextBox3.Text
            Label12.Text = TextBox1.Text
        ElseIf Val(TextBox1.Text) > Val(TextBox3.Text) Then
            Label10.Text = TextBox1.Text
            Label12.Text = TextBox3.Text
        ElseIf Val(TextBox3.Text) > Val(TextBox2.Text) Then
            Label10.Text = TextBox3.Text
            Label12.Text = TextBox2.Text
        ElseIf Val(TextBox2.Text) > Val(TextBox3.Text) Then
            Label10.Text = TextBox2.Text
            Label12.Text = TextBox3.Text

        ElseIf Val(TextBox1.Text) > Val(TextBox2.Text) Or Val(TextBox3.Text) Then
            Label10.Text = TextBox1.Text
        ElseIf Val(TextBox2.Text) > Val(TextBox1.Text) Or Val(TextBox3.Text) Then
            Label10.Text = TextBox2.Text
        ElseIf Val(TextBox3.Text) > Val(TextBox2.Text) Or Val(TextBox1.Text) Then
            Label10.Text = TextBox3.Text

        ElseIf Val(TextBox1.Text) < Val(TextBox2.Text) Or Val(TextBox3.Text) Then
            Label12.Text = TextBox1.Text
        ElseIf Val(TextBox2.Text) < Val(TextBox1.Text) Or Val(TextBox3.Text) Then
            Label12.Text = TextBox2.Text
        ElseIf Val(TextBox3.Text) < Val(TextBox2.Text) Or Val(TextBox1.Text) Then
            Label12.Text = TextBox3.Text

        Else
            Label10.Text = ""
            Label12.Text = ""

        End If


        If Val(TextBox1.Text) = Val(TextBox3.Text) = Val(TextBox2.Text) Then
            Label14.Text = TextBox1.Text
        ElseIf Val(TextBox1.Text) = Val(TextBox2.Text) Then
            Label14.Text = TextBox1.Text
        ElseIf Val(TextBox2.Text) = Val(TextBox3.Text) Then
            Label14.Text = TextBox2.Text
        ElseIf Val(TextBox3.Text) = Val(TextBox1.Text) Then
            Label14.Text = TextBox3.Text
        Else
            Label14.Text = ""

        End If
    End Sub

Recommended Answers

All 3 Replies

What exactly is happening wrong? I've ran it but without knowing which pattern
Is malfunctioning its hard to duplicate the problem

sometimes the textboxes don't compare with each other.

see if that helps...

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		Dim numbers() As Integer = {CInt(TextBox1.Text), CInt(TextBox2.Text), CInt(TextBox3.Text)}
		Label10.Text = CStr(numbers.Max)
		Label12.Text = CStr(numbers.Min)
		Dim tmpArray As New ArrayList 'to hold the uniq numbers

		For Each num As Integer In numbers
			Dim i As Integer = num
			If Not tmpArray.Contains(num) AndAlso numbers.Where(Function(s) s = i).Count > 1 Then
				tmpArray.Add(num)
			End If
		Next
		Label14.Text = String.Join(", ", tmpArray.ToArray)
	End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.