Bueno mientras no me jales de las orejas,de las patillas ,no me des con la regla en los dedos ni me pongas de rodillas con una tapas de refrescos jejej como era antes,
bueno aca esta la version cortita
bueno aca esta la version cortita
Código (vbnet) [Seleccionar]
Public Class Form1
ReadOnly MAX As Integer = 99
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim arregloSumasa() As Integer = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21}
Dim split As IEnumerable(Of IEnumerable(Of Integer)) =
SplitIntoParts(collection:=arregloSumasa, amount:=2, fillEmpty:=True)
' *****************************************************************************************************
Dim Bz990 As IEnumerable(Of Integer) =
(
From Value As Integer In split(0).Concat(split(1)).Concat(split(2)).Concat(split(3)).Concat(split(4))
Where (Value <= MAX AndAlso Value > 0)).Distinct
Dim Sl990 As IEnumerable(Of Integer) = Bz990
Dim SM990 As List(Of Integer) = Bz990.Take(10).ToList
SM990.Sort()
Me.ListBox1.Items.AddRange((From value As Integer In SM990 Where value <> 0).Cast(Of Object).ToArray)
' *******************************************************************************************************
'este codigo ahora
' muestra -------> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
' yo quiero mostrar --> 1, 3, 5, 7, 9, 11,13,15,17, 19 <--- ojo no son numeros pares ni impares, es por posiciones
' yo quiero mostrar --> 2, 4, 6, 8, 10, 12,14,16,18.20 <---estan ordenados para el ejemplo
End Sub
Public Shared Function SplitIntoParts(Of T)(ByVal collection As IEnumerable(Of T),
ByVal amount As Integer,
ByVal fillEmpty As Boolean) As IEnumerable(Of IEnumerable(Of T))
Return From index As Integer In Enumerable.Range(0, CInt(Math.Ceiling(collection.Count() / amount)))
Select If(Not fillEmpty,
collection.Skip(index * amount).Take(amount),
If((collection.Count() - (index * amount)) >= amount,
collection.Skip(index * amount).Take(amount),
collection.Skip(index * amount).Take(amount).
Concat(From i As Integer
In Enumerable.Range(0, amount - (collection.Count() - (index * amount)))
Select DirectCast(Nothing, T))))
End Function