Public Class Form1
Dim maximum As Short = 99
Dim Número As Double
Private TextBoxes As TextBox() = {Nothing}
Private Result1 As Int32(), Result2 As Int32(), Result3 As Int32(), Result4 As Int32(), Result5 As Int32(), Result6 As Int32(), Result7 As Int32(), Result8 As Int32(), Result9 As Int32(), Result10 As Int32(), Result11 As Int32(), Result12 As Int32(), Result13 As Int32(), Result14 As Int32(), Result15 As Int32(), Result16 As Int32(), Result17 As Int32(), Result18 As Int32(), Result19 As Int32(), Result20 As Int32()
Private _textBox As Object
ReadOnly MAX As Integer = 99
Dim Rand As New Random
Dim Rand2 As New Random
Dim Result22 As Integer
Dim Counter, Counter2 As Integer
Dim myLabelArray(6) As Label
Dim x As Integer = 0
Private Property ListBox1Count As Integer
ReadOnly Randomizer As New Random
Dim Combo As List(Of Integer) = Nothing
Dim Combos As New List(Of List(Of Integer))
Dim FixedValues As Integer() = Nothing
ReadOnly RandomValues As Integer() =
Enumerable.Range(0, 99).ToArray
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
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
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
ReadOnly Property Num4 As Int32
Get
Return CInt(TextBox4.Text)
End Get
End Property
ReadOnly Property Num5 As Int32
Get
Return CInt(TextBox5.Text)
End Get
End Property
'---------------------------------
ReadOnly Property Num6 As Int32
Get
Return CInt(TextBox6.Text)
End Get
End Property
ReadOnly Property Num7 As Int32
Get
Return CInt(TextBox7.Text)
End Get
End Property
ReadOnly Property Num8 As Int32
Get
Return CInt(TextBox8.Text)
End Get
End Property
ReadOnly Property Num9 As Int32
Get
Return CInt(TextBox9.Text)
End Get
End Property
ReadOnly Property Num10 As Int32
Get
Return CInt(TextBox10.Text)
End Get
End Property
ReadOnly Property Num11 As Int32
Get
Return CInt(TextBox11.Text)
End Get
End Property
ReadOnly Property Num12 As Int32
Get
Return CInt(TextBox12.Text)
End Get
End Property
ReadOnly Property Num13 As Int32
Get
Return CInt(TextBox13.Text)
End Get
End Property
ReadOnly Property Num14 As Int32
Get
Return CInt(TextBox14.Text)
End Get
End Property
ReadOnly Property Num15 As Int32
Get
Return CInt(TextBox15.Text)
End Get
End Property
ReadOnly Property Num16 As Int32
Get
Return CInt(TextBox16.Text)
End Get
End Property
ReadOnly Property Num17 As Int32
Get
Return CInt(TextBox17.Text)
End Get
End Property
ReadOnly Property Num18 As Int32
Get
Return CInt(TextBox18.Text)
End Get
End Property
ReadOnly Property Num19 As Int32
Get
Return CInt(TextBox19.Text)
End Get
End Property
ReadOnly Property Num20 As Int32
Get
Return CInt(TextBox20.Text)
End Get
End Property
Private Sub Sumar(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
'--------------------------------------------------
Dim Result1 As Integer() = {Num1 - 1, Num1 - 2, Num1 - 3, Num1 + 1, Num1 + 2, Num1 + 3}
For Index As Integer = 0 To (Result1.Count - 1)
Select Case Result1(Index)
Case Is = 0 ' El valor es 0. esto todavia no me funciona
' Hacer algo con el número 0 aquí. no mostrar el 0
' Result1(Index) = Not 0
Case Is < 0 ' El valor es negativo.
' Lo convierto a positivo si funciona.
Result1(Index) = Math.Abs(Result1(Index))
End Select '/ Result1(Index)
Next Index
Result1 = Result1.Distinct().ToArray
Array.Sort(Result1)
'---------------------------------------------------
Result2 = {Num2 + 1, Num2 + 2, Num2 + 3, Num2 - 1, Num2 - 2} _
.Distinct().ToArray
Array.Sort(Result2)
Result3 = {Num3 + 1, Num3 + 2, Num3 + 3, Num3 - 1, Num3 - 2, Num3 - 3} _
.Distinct().ToArray
Array.Sort(Result3)
Result4 = {Num4 + 1, Num4 + 2, Num4 + 3, Num4 - 1, Num4 - 2, Num4 - 3} _
.Distinct().ToArray
Array.Sort(Result4)
Result5 = {Num5 + 1, Num5 + 2, Num5 + 3, Num5 - 1, Num5 - 2, Num5 - 3} _
.Distinct().ToArray
Array.Sort(Result5)
Result6 = {Num6 + 1, Num6 + 2, Num6 + 3, Num6 - 1, Num6 - 2, Num6 - 3} _
.Distinct().ToArray
Array.Sort(Result6)
Result7 = {Num7 + 1, Num7 + 2, Num7 + 3, Num7 - 1, Num7 - 2, Num7 - 3} _
.Distinct().ToArray
Array.Sort(Result7)
Result8 = {Num8 + 1, Num8 + 2, Num8 + 3, Num8 - 1, Num8 - 2, Num8 - 3} _
.Distinct().ToArray
Array.Sort(Result8)
Result9 = {Num9 + 1, Num9 + 2, Num9 + 3, Num9 - 1, Num9 - 2, Num9 - 3} _
.Distinct().ToArray
Array.Sort(Result9)
Result10 = {Num10 + 1, Num10 + 2, Num10 - 1, Num10 - 2, Num10 - 3} _
.Distinct().ToArray
Array.Sort(Result10)
Result11 = {Num11 + 1, Num11 + 2, Num11 + 3, Num11 - 1, Num11 - 2, Num11 - 3} _
.Distinct().ToArray
Array.Sort(Result11)
Result12 = {Num12 + 1, Num12 + 2, Num12 + 3, Num12 - 1, Num12 - 2, Num12 - 3} _
.Distinct().ToArray
Array.Sort(Result12)
Result13 = {Num13 + 1, Num13 + 2, Num13 + 3, Num13 - 1, Num13 - 2, Num13 - 3} _
.Distinct().ToArray
Array.Sort(Result13)
Result14 = {Num14 + 1, Num14 + 2, Num14 + 3, Num14 - 1, Num14 - 2, Num14 - 3} _
.Distinct().ToArray
Array.Sort(Result14)
Result15 = {Num15 + 1, Num15 + 2, Num15 + 3, Num15 - 1, Num15 - 2, Num15 - 3} _
.Distinct().ToArray
Array.Sort(Result15)
Result16 = {Num16 + 1, Num16 + 2, Num16 + 3, Num16 - 1, Num16 - 2, Num16 - 3} _
.Distinct().ToArray
Array.Sort(Result16)
Result17 = {Num17 + 1, Num17 + 2, Num17 + 3, Num17 - 1, Num17 - 2, Num17 - 3} _
.Distinct().ToArray
Array.Sort(Result17)
Result18 = {Num18 + 1, Num18 + 2, Num18 + 3, Num18 - 1, Num18 - 2, Num18 - 3} _
.Distinct().ToArray
Array.Sort(Result18)
Result19 = {Num19 + 1, Num19 + 2, Num19 + 3, Num19 - 1, Num19 - 2, Num19 - 3} _
.Distinct().ToArray
Array.Sort(Result19)
Result20 = {Num20 + 1, Num20 + 2, Num20 + 3, Num20 - 1, Num20 - 2, Num20 - 3} _
.Distinct().ToArray
Array.Sort(Result20)
' Elimino duplicados al mismo tiempo que selecciono los números inferiores a MAX.
Dim Resultss As IEnumerable(Of Integer) =
(
From Value As Integer
In (Result1.Concat(Result2).Concat(Result3).Concat(Result4).Concat(Result5).Concat(Result6).Concat(Result7).Concat(Result8).Concat(Result9).Concat(Result10).Concat(Result11).Concat(Result12).Concat(Result13).Concat(Result14).Concat(Result15).Concat(Result16).Concat(Result17).Concat(Result18).Concat(Result19).Concat(Result20)).Distinct
Where Value <= MAX
)
ListBox2.Items.AddRange(Resultss.Cast(Of Object).ToArray)
'funcion unir combis
FixedValues =
((Result1.Concat(Result2).Concat(Result3).Concat(Result4).Concat(Result5).Concat(Result6).Concat(Result7).Concat(Result8).Concat(Result9).Concat(Result10).Concat(Result11).Concat(Result12).Concat(Result13).Concat(Result14).Concat(Result15).Concat(Result16).Concat(Result17).Concat(Result18).Concat(Result19).Concat(Result20)).Distinct).
Distinct.
Select(Function(Value As Integer)
Return If(Value < MAX, Value, Rand.Next(0, MAX))
End Function).ToArray
Dim IndexCounter As Integer = FixedValues.First ' 1
Dim LenCounter As Integer = 0I
Const NumStep As Integer = 3I
Const NumLen As Integer = 10I
Do Until IndexCounter > FixedValues.Last
Combo = New List(Of Integer)
For Num As Integer = IndexCounter To (FixedValues.Count - 1I) Step NumStep
LenCounter += 1I
Combo.Add(FixedValues(Num - 1I)) 'matrix fuersa
If LenCounter >= NumLen Then
Exit For
End If
Next Num
If LenCounter < NumLen Then
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
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
' Application.Exit()
Private Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
sender.text = System.Text.RegularExpressions.Regex.Replace(sender.text, "\D", "")
End Sub
Private Sub TextBox3_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
sender.text = System.Text.RegularExpressions.Regex.Replace(sender.text, "\D", "")
End Sub
Private Sub TextBox4_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
sender.text = System.Text.RegularExpressions.Regex.Replace(sender.text, "\D", "")
End Sub
Private Sub TextBox5_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
sender.text = System.Text.RegularExpressions.Regex.Replace(sender.text, "\D", "")
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
sender.text = System.Text.RegularExpressions.Regex.Replace(sender.text, "\D", "")
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
solonumeros(e)
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
solonumeros(e)
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
solonumeros(e)
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
Private Sub TextBox4_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox4.KeyPress
solonumeros(e)
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
Private Sub TextBox5_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox5.KeyPress
solonumeros(e)
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
Private Sub TextBox6_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox6.KeyPress
solonumeros(e)
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
Private Sub TextBox7_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox7.KeyPress
solonumeros(e)
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
Private Sub TextBox8_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox8.KeyPress
solonumeros(e)
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
Private Sub TextBox9_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox9.KeyPress
solonumeros(e)
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
Private Sub TextBox10_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox10.KeyPress
solonumeros(e)
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
Private Sub TextBox11_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox11.KeyPress
solonumeros(e)
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
Private Sub TextBox12_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox12.KeyPress
solonumeros(e)
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
Private Sub TextBox13_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox13.KeyPress
solonumeros(e)
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
Private Sub TextBox14_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox14.KeyPress
solonumeros(e)
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
Private Sub TextBox15_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox15.KeyPress
solonumeros(e)
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
Private Sub TextBox16_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox16.KeyPress
solonumeros(e)
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
Private Sub TextBox17_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox17.KeyPress
solonumeros(e)
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
Private Sub TextBox18_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox18.KeyPress
solonumeros(e)
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
Private Sub TextBox19_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox19.KeyPress
solonumeros(e)
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
Private Sub TextBox20_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox20.KeyPress
solonumeros(e)
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
For Each obj As Control In Me.Controls
If (TypeOf obj Is TextBox) Then
obj.Text = ""
End If
If (TypeOf obj Is GroupBox) Then
For Each caja As Control In obj.Controls
If (TypeOf caja Is TextBox) Then
caja.Text = ""
End If
Next
End If
ListBox1.Items.Clear()
Next
End Sub
End Class