0

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
3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by GeekByChoiCe
0

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

0

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
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.