Al ataque de nuevo jeje bueno ya ustedes saben como se frustra uno cuando no se logra hacer funcionar algo, vueltas y vueltas y nada tengo el siguiente programa que funciona bien hasta llegar a la función de combinar los numeros pero es un código de basic que quiero implementar pero no soy capaz ( como siempre)
Código (vbnet) [Seleccionar]
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
Dim auxiliar As Integer
Dim auxiliar1 As Integer
Dim auxiliar2 As String
Dim auxiliar3 As String
Dim anterior As String
Dim recorrer As Integer
Dim recorrer1 As Integer
Dim recorrer2 As Integer
Dim recorrer3 As Integer
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)
' Result2---------------------------------------------------------
Dim Rand2 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 Result22 As IEnumerable(Of Integer) =
(Result1).
Distinct.
Select(Function(Value As Integer)
Return If(Value < MAX, Value, Rand.Next(0, MAX))
End Function)
ListBox2.Items.AddRange(Result22.Cast(Of Object).ToArray)
Dim Rand22 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 Result222 As IEnumerable(Of Integer) =
(Result2).
Distinct.
Select(Function(Value As Integer)
Return If(Value < MAX, Value, Rand.Next(0, MAX))
End Function)
ListBox3.Items.AddRange(Result222.Cast(Of Object).ToArray)
End Sub
' funcion combinar la variable " resul " que contiene la cantidad de numeros a combinar (no funciona)
' esto es de basic pero es para cojer la idea :) no se como hacerlo en net
For recorrer = 1 To Len(resul)
auxiliar = Mid(palabra, recorrer, 1)
For recorrer1 = 1 To Len(resul)
auxiliar1 = Mid(palabra, recorrer1, 1)
For recorrer2 = 1 To Len(resul)
auxiliar2 = Mid(palabra, recorrer2, 1)
For recorrer3 = 1 To Len(resul)
auxiliar3 = Mid(resul, recorrer3, 1)
If anterior <> auxiliar3 Then
Print(auxiliar & auxiliar1 & auxiliar2 & auxiliar3) <------------mostrar esto en un lixbox
End If
anterior = auxiliar3
Next
Next
Next
Next
End Sub
'--------------------------- limpiar texboxes
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()
ListBox2.Items.Clear()
ListBox3.Items.Clear()
Next
End Sub
End Class