Imports System.IO
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()
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
Private Sub Sumar(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
'--------------------------------------------------
Result1 = {Num1 + 2, Num1 + 3, Num1 \ 2, Num1 \ 3, Num1 * 3} _
.Distinct().ToArray
Array.Sort(Result1)
Result2 = {Num2 + 2, Num2 + 3, Num2 \ 2, Num2 \ 3, Num2 * 3} _
.Distinct().ToArray
Array.Sort(Result2)
Result3 = {Num3 + 2, Num3 + 3, Num3 - 2, Num3 - 3, Num3 * 3, Num3 \ 2, Num3 \ 2} _
.Distinct().ToArray
Array.Sort(Result3)
Result4 = {Num4 + 2, Num4 + 3, Num4 - 2, Num4 - 3, Num4 * 2, Num4 * 3, Num4 \ 2, Num4 \ 3} _
.Distinct().ToArray
Array.Sort(Result4)
Result5 = {Num5 + 2, Num5 + 3, Num5 - 3, Num5 - 10, Num5 * 3, Num5 \ 2, Num5 \ 3, Num5 \ 4} _
.Distinct().ToArray
Array.Sort(Result5)
Result6 = {Num6 + 2, Num6 + 3, Num6 - 2, Num6 - 3, Num6 - 7, Num6 \ 2, Num6 \ 3} _
.Distinct().ToArray
Array.Sort(Result6)
' 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)).Distinct
Where Value <= MAX
)
ListBox1.Items.AddRange(Resultss.Cast(Of Object).ToArray)
ListBox1.Sorted = True
'funcion unir combis
Dim constantValues As IEnumerable(Of Integer) =
(
From Value As Integer
In (Result1.Concat(Result2).Concat(Result3).Concat(Result4).Concat(Result5).Concat(Result6)).Distinct
Where Value <= MAX
)
' Application.Exit()
End Sub
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 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
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim rutaFichero As String
Dim i As Integer
rutaFichero = Path.Combine(Application.StartupPath, "Multiples.txt")
Dim fichero As New IO.StreamWriter(rutaFichero)
For i = 0 To ListBox1.Items.Count - 1
fichero.WriteLine(ListBox1.Items(i))
Next
fichero.Close()
End Sub
Dim combinations As Integer
Dim seta As Integer
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim constantValues As New List(Of Integer)
Dim combinations As New List(Of List(Of Integer))
Dim length As Integer = 5
Dim skipStart As Integer = 0
Do Until skipStart = (constantValues.Count - length)
Dim values As List(Of Integer) = constantValues.GetRange(skipStart, length)
Dim count As Integer = 0
Do Until count = (constantValues.Count - length - skipStart)
combinations.Add(values.Concat(constantValues.Skip(skipStart + length + count).Take(1)).ToList)
Debug.
WriteLine(String.
Join(", ", values.
Concat(constantValues.
Skip(skipStart
+ length
+ count
).
Take(1)).
ToArray))
count += 1
Loop ' count = (constantValues.Count - length)
skipStart += 1
skipStart = 0
Loop ' skipStart = (constantValues.Count - length)
combinations.ForEach(Sub(combination As List(Of Integer))
ListBox1.Items.Add(String.Join(", ", From value As Integer In combination
Select If(value.ToString.Length = 1I,
value.ToString.Insert(0I, "0"c),
value.ToString)))
End Sub)
End Sub