Ya funciona y estoy tratando de eliminar repetidos con:)
.Distinct().ToArray() ' Eliminar duplicados pero no va
Lo de ordenar ya se como se hace
Luis
.Distinct().ToArray() ' Eliminar duplicados pero no va
Lo de ordenar ya se como se hace
Código (vbnet) [Seleccionar]
Public Class Form1
Dim maximum As Short = 49
Dim x As Integer = 0
Dim Número As Double
Private TextBoxes As TextBox() = {Nothing}
Private Result1 As Int32(), Result2 As Int32()
Private _textBox As Object
Private Property ListBox1Count As Integer
Private Sub FrmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.ControlBox = False ' Elimino todos los controles del formulario
End Sub
Private Property Calcular As Object
Private Property TextBox(ByVal TextBoxCount As Short) As Object
Get
Return _textBox
End Get
Set(ByVal value As Object)
_textBox = value
End Set
End Property
Public Sub solonumeros(ByRef e As System.Windows.Forms.KeyPressEventArgs)
' evitar letras
If Char.IsDigit(e.KeyChar) Then
e.Handled = False
ElseIf Char.IsControl(e.KeyChar) Then
e.Handled = False
ElseIf Char.IsSeparator(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
End If
End Sub
ReadOnly Property Num1 As Int32
Get
Return CInt(TextBox1.Text)
End Get
End Property
ReadOnly Property Num2 As Int32
Get
Return CInt(TextBox2.Text)
End Get
End Property
Private Sub Sumar(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Result1 = {Num1 + 10, Num1 + 20, Num1 + 30} _
.Distinct().ToArray ' Elimino duplicados
Result2 = {Num2 + 10, Num2 + 20, Num2 + 30} _
.Distinct().ToArray ' Elimino duplicad
Array.Sort(Result1) : Array.Sort(Result2) ' El número no está repetido:
Dim Results As IEnumerable(Of Integer) =
Result1 ' El número no está repetido.Concat(Result2)
For X As Integer = 0 To Results.Count - 1
Dim Items1 As List(Of String) = ListBox1.Items.Cast(Of String)().ToList
Items1.Add(" ")
Dim Items2 As List(Of String) = ListBox2.Items.Cast(Of String)().ToList
Items2.Add(" ")
Dim CombinedItems As List(Of String) = Items1.Concat(Items2).ToList
ListBox3.Items.AddRange(CombinedItems.ToArray)
Select Case Results.Where(Function(n) n = Results(X)).Skip(1).Any
Case False ' El número no está repetido en ninguna "linea"
' Así que colocamos el número en el Textbox
Try
ListBox1.Items.Add(CStr(Results(X)))
' TextBoxes(TextBoxCount).Text = CStr(Results(X))
Catch ex As Exception
Throw New Exception(ex.Message & ex.StackTrace)
End Try
End Select
Next X
' -------segunda
Dim Resultss As IEnumerable(Of Integer) =
Result2 ' .
For X As Integer = 0 To Resultss.Count - 1
Select Case Resultss.Where(Function(n) n = Resultss(X)).Skip(1).Any
Case False
Try
ListBox2.Items.Add(CStr(Resultss(X)))
Catch ex As Exception
Throw New Exception(ex.Message & ex.StackTrace)
End Try
End Select
Next X
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Luis