jeje AUXILIO, No de verdad que no tengo nocion de como unir esto ;( ya sera que confundo mucho con tantas cosas a la ves
Cuando lo ejecuto de una ves me hace lo del segundo codigo y se supone que debe ser cuando se ejecute el primero y cambie los valores de " FixedValues " con los de " Result "
Chapuza que tengo echa
Cuando lo ejecuto de una ves me hace lo del segundo codigo y se supone que debe ser cuando se ejecute el primero y cambie los valores de " FixedValues " con los de " Result "
Chapuza que tengo echa
Código (vbnet) [Seleccionar]
Imports System.IO
Public 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(), Result3 As Int32()
Private _textBox As Object
Private Property ListBox1Count As Integer
ReadOnly MAX As Integer = 99
ReadOnly Randomizer As New Random
Dim Combo As List(Of Integer) = Nothing
Dim Combos As New List(Of List(Of Integer))
ReadOnly FixedValues As Integer() = {1, 5, 10, 15, 20, 25, 30, 33, 35, 38, 40, 45, 48}
ReadOnly RandomValues As Integer() =
Enumerable.Range(FixedValues.First, FixedValues.Last).ToArray ' 1 to 30
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
ReadOnly Property Num3 As Int32
Get
Return CInt(TextBox3.Text)
End Get
End Property
Private Sub Sumar(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Result1 = {Num1 + 1, Num1 + 2, Num1 + 4, Num1 + 6, Num1 - 4, Num1 - 1} _
.Distinct().ToArray ' Elimino duplicados
Result2 = {Num2 + 1, Num2 + 2, Num2 + 3, Num2 - 1, Num2 - 2, Num1 - 3} _
.Distinct().ToArray ' Elimino duplicados
Result3 = {Num3 - 1, Num3 - 2, Num3 - 3, Num3 + 2, Num3 + 3, Num3 + 5} _
.Distinct().ToArray ' Elimino duplicados
Dim Rand As New Random
' Concateno, y...
' Elimino duplicados, y...
' Selecciono los números inferiores a MAX, y...
' Convierto los números mayores a MAX a números aleatorios entre 0 y MAX.
Dim Result As IEnumerable(Of Integer) =
(Result1.Concat(Result2).Concat(Result3)).
Distinct.
Select(Function(Value As Integer)
Return If(Value < MAX, Value, Rand.Next(0, MAX))
End Function)
ListBox1.Items.AddRange(Result.Cast(Of Object).ToArray)
' ******** ------------------------------------------------------------------
' Num ReadOnly FixedValues As Integer() =
' Num Enumerable.Range(1I, 49I).ToArray ' 1 to 30
End Sub
Private Sub Test() Handles MyBase.Shown
Dim IndexCounter As Integer = FixedValues.First ' 1
Dim LenCounter As Integer = 0I
Const NumStep As Integer = 5I
Const NumLen As Integer = 6I
Do Until IndexCounter > FixedValues.Last ' IndexCounter > 30
Combo = New List(Of Integer)
For Num As Integer = IndexCounter To (FixedValues.Count) Step NumStep
LenCounter += 1I
Combo.Add(FixedValues(Num - 1I))
If LenCounter >= NumLen Then
Exit For
End If
Next Num
If LenCounter < NumLen Then ' If LenCounter < 10
For RandomNum As Integer = 1I To (NumLen - LenCounter)
Dim n As Integer = Randomizer.Next(RandomValues.First, RandomValues.Last)
Do Until Not Combo.Contains(n)
n = Randomizer.Next(RandomValues.First, RandomValues.Last)
Loop
Combo.Add(n)
Next ' RandomNum
End If ' LenCounter < NumLen
#If DEBUG Then ' #Debug
Debug.WriteLine(String.Join(", ", Combo))
' Stop
#End If
Combo.Sort()
Combos.Add(Combo)
IndexCounter += 1I
LenCounter = 0I
Loop ' IndexCounter >= FixedValues.Last
' ******** ordenamiento-------------
' Dim values As Integer() = (From n As Integer In Combos Order By n Ascending).ToArray
' ********
' Listbox:
' ********
Combos.ForEach(Sub(comb As List(Of Integer))
' Convierto la Lista a 'String', le añado los ceros, y añado el string formateado al Listbox.
ListBox1.Items.Add(String.Join(", ",
From value As String In comb
Select If(value.Length = 1I,
value.Insert(0I, "0"c),
value)))
ListBox1.Sorted = True
End Sub)
End Sub ' Test
End Class