There are 8 outputs and each of them, is identified with a letter from A
to H
. Each output will have a variable ( TextBox
) where the user will only put numbers and when they finish adding the numbers, they want to make an operation:
Ideally, in all exits have a different number.
For example:
Salida A B C D E F G H
variable 1 2 3 4 5 6 7 8
But the problem is generated when there are equal numbers.
Salida A B C D E F G H
variable 1 1 2 3 4 5 6 6
For Visual Studio it is necessary to count the equalities in this case 2
, save this number and project and identify the outputs that are equal, in this case A B , G H
and expose them.
The variables are TextBox
, and the outputs are labels .
Example 2:
Salida A B C D E F G H
variable 4 3 2 3 4 5 5 6
equalities = 3
Equal outputs: AD, BD, FG
Code VB.NET (what I tried to do):
Public Class Form1
Dim iguales As Integer
Private txt As String
Dim i As Integer
Dim u As Integer
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
iguales = 0
txt = ""
For i = 1 To 7
For u = i + 1 To 8
If Me.Controls("TextBox" & i.ToString).Text = Me.Controls("TextBox" & u.ToString).Text Then
// ' U es igual I
iguales = iguales + 1
txt = txt + u + i + ", "
End If
Next
Next
txt = RichTextBox1.Text
iguales = RichTextBox2.Text
End Sub
End Class