- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
'Hello, I need your help for the following
'I have 2 lists.
Public ListBD As New List(Of Tuple(Of String, String, String))
Public ListAcc As New List(Of Tuple(Of String, Double))
I have linked them by the first item (description). Now I get the description field of ListBD, code of ListBD and Quantity of ListAcc. This works perfect
Dim RptCargador = From Datos In ListBD, Datos1 In ListAcc
Where Datos.Item1 = Datos1.Item1
Order By Datos.Item3
Select Descripcion = Datos.Item3, Codigo = Datos.Item2, Cantidad = Datos1.Item2
Libro.Sheets(1).cells(1, 1) = "Código"
Libro.Sheets(1).cells(1, 2) = "Cantidad"
Libro.Sheets(1).cells(1, 3) = "Descripción de Artículo"
For Each valor In RptCargador
Libro.Sheets(1).cells(i, 1) = valor.Codigo
Libro.Sheets(1).cells(i, 2) = valor.Cantidad
Libro.Sheets(1).cells(i, 3) = valor.Descripcion
i = i + 1
Next
'What is what I need.
'I need the data that does not match the item1 of ListAcc and the item1 of ListBD
'In the attached file there is an example.
I have solved it by doing one cycle inside another. But this takes a long time, it is very slow. This is how I did it. I hope you can give me a better shape.
#Region "Datos No Encontrados"
Dim RptCargador1 = From Datos In ListAcc
Select Datos.Item1, Datos.Item2
For Each valor In RptCargador1
Dim diferente As Boolean : Dim igual As Boolean
Dim RptCargador2 = From Datos1 In ListBD
Select Datos1.Item1
diferente = False : igual = False
For Each valor2 In RptCargador2
If valor.Item1 <> valor2 Then
diferente = True
Else
igual = True
End If
Next
If diferente = True And igual = False Then
Libro.Sheets(1).cells(i, 2) = valor.Item2
Libro.Sheets(1).cells(i, 3) = valor.Item1
i = i + 1
End If
Next
#End Region
I hope you can give me a better shape. Maybe similar to the one I developed for the first part
Thank you
Solved! Go to Solution.