Código
Hola a todos espero que hayan pasado buenas fiestas :) Me he pasado el tiempo tratando de hacer esto pero no encuentro el como quiero concatenar dos array para que: Result1.Concat(Result2) comparar si hay iguales y si hay iguales recorrer el rango y sustituir el repetido por el que no aparezca. ya elimino duplicados pero en cada array, y no se como hacerlo con el resultado final que se mostraria en e lisboxt3 ListBox3.Items.AddRange(CombinedItems.ToArray) [codePublic Class Form1 Dim maximum As Short = 99 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 ' Este es para unir en 3lisbos 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) ' aqui acaba 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]
saludos
Luis