elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Introducción a Git (Primera Parte)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  Mis malas combinaciones :(
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: 1 2 3 4 [5] 6 Ir Abajo Respuesta Imprimir
Autor Tema: Mis malas combinaciones :(  (Leído 21,885 veces)
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Mis malas combinaciones :(
« Respuesta #40 en: 29 Agosto 2014, 17:33 pm »

1) pon el código entero que estás usando

2) a la variable FixedValues asignale manualmente los numeros que tocan ( que no lo tenga q hacer yo porque no los se :-/ ) para probar el For.

3) pon el output que debería dar al menos las primeras 3 combinaciones para saber por donde corregir el problema...

saludos!


En línea

luis456


Desconectado Desconectado

Mensajes: 548



Ver Perfil
Re: Mis malas combinaciones :(
« Respuesta #41 en: 29 Agosto 2014, 18:09 pm »

Hola pongo el código entero, lo de poner los números en la variable es como difícil sin tener que cortar el código, que como veras hace una serie de cálculos con 20 dígitos que introduzco y saber cuantos números salen de esa ecuación es un poco difícil


Codigo

Código
  1. Public Class Form1
  2.    Dim maximum As Short = 99
  3.    Dim Número As Double
  4.    Private TextBoxes As TextBox() = {Nothing}
  5.    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()
  6.    Private _textBox As Object
  7.    ReadOnly MAX As Integer = 99
  8.    Dim Rand As New Random
  9.    Dim Rand2 As New Random
  10.    Dim Result22 As Integer
  11.    Dim Counter, Counter2 As Integer
  12.    Dim myLabelArray(6) As Label
  13.    Dim x As Integer = 0
  14.    Private Property ListBox1Count As Integer
  15.    ReadOnly Randomizer As New Random
  16.    Dim Combo As List(Of Integer) = Nothing
  17.    Dim Combos As New List(Of List(Of Integer))
  18.    Dim FixedValues As Integer() = Nothing
  19.    ReadOnly RandomValues As Integer() =
  20.        Enumerable.Range(0, 99).ToArray
  21.  
  22.    Public Sub solonumeros(ByRef e As System.Windows.Forms.KeyPressEventArgs)
  23.        ' evitar letras
  24.        If Char.IsDigit(e.KeyChar) Then
  25.            e.Handled = False
  26.        ElseIf Char.IsControl(e.KeyChar) Then
  27.            e.Handled = False
  28.        ElseIf Char.IsSeparator(e.KeyChar) Then
  29.            e.Handled = False
  30.        Else
  31.            e.Handled = True
  32.        End If
  33.  
  34.    End Sub
  35.  
  36.    Private Property Calcular As Object
  37.  
  38.    Private Property TextBox(ByVal TextBoxCount As Short) As Object
  39.        Get
  40.            Return _textBox
  41.        End Get
  42.        Set(ByVal value As Object)
  43.            _textBox = value
  44.        End Set
  45.    End Property
  46.  
  47.    ReadOnly Property Num1 As Int32
  48.        Get
  49.            Return CInt(TextBox1.Text)
  50.        End Get
  51.    End Property
  52.    ReadOnly Property Num2 As Int32
  53.        Get
  54.            Return CInt(TextBox2.Text)
  55.        End Get
  56.    End Property
  57.    ReadOnly Property Num3 As Int32
  58.        Get
  59.            Return CInt(TextBox3.Text)
  60.        End Get
  61.    End Property
  62.    ReadOnly Property Num4 As Int32
  63.        Get
  64.            Return CInt(TextBox4.Text)
  65.        End Get
  66.    End Property
  67.  
  68.    ReadOnly Property Num5 As Int32
  69.        Get
  70.            Return CInt(TextBox5.Text)
  71.        End Get
  72.    End Property
  73.    '---------------------------------
  74.    ReadOnly Property Num6 As Int32
  75.        Get
  76.            Return CInt(TextBox6.Text)
  77.        End Get
  78.    End Property
  79.  
  80.    ReadOnly Property Num7 As Int32
  81.        Get
  82.            Return CInt(TextBox7.Text)
  83.        End Get
  84.    End Property
  85.    ReadOnly Property Num8 As Int32
  86.        Get
  87.            Return CInt(TextBox8.Text)
  88.        End Get
  89.    End Property
  90.    ReadOnly Property Num9 As Int32
  91.        Get
  92.            Return CInt(TextBox9.Text)
  93.        End Get
  94.    End Property
  95.    ReadOnly Property Num10 As Int32
  96.        Get
  97.            Return CInt(TextBox10.Text)
  98.        End Get
  99.    End Property
  100.    ReadOnly Property Num11 As Int32
  101.        Get
  102.            Return CInt(TextBox11.Text)
  103.        End Get
  104.    End Property
  105.    ReadOnly Property Num12 As Int32
  106.        Get
  107.            Return CInt(TextBox12.Text)
  108.        End Get
  109.    End Property
  110.    ReadOnly Property Num13 As Int32
  111.        Get
  112.            Return CInt(TextBox13.Text)
  113.        End Get
  114.    End Property
  115.    ReadOnly Property Num14 As Int32
  116.        Get
  117.            Return CInt(TextBox14.Text)
  118.        End Get
  119.    End Property
  120.    ReadOnly Property Num15 As Int32
  121.        Get
  122.            Return CInt(TextBox15.Text)
  123.        End Get
  124.    End Property
  125.  
  126.    ReadOnly Property Num16 As Int32
  127.        Get
  128.            Return CInt(TextBox16.Text)
  129.        End Get
  130.    End Property
  131.    ReadOnly Property Num17 As Int32
  132.        Get
  133.            Return CInt(TextBox17.Text)
  134.        End Get
  135.    End Property
  136.    ReadOnly Property Num18 As Int32
  137.        Get
  138.            Return CInt(TextBox18.Text)
  139.        End Get
  140.    End Property
  141.    ReadOnly Property Num19 As Int32
  142.        Get
  143.            Return CInt(TextBox19.Text)
  144.        End Get
  145.    End Property
  146.    ReadOnly Property Num20 As Int32
  147.        Get
  148.            Return CInt(TextBox20.Text)
  149.        End Get
  150.    End Property
  151.  
  152.    Private Sub Sumar(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
  153.        '--------------------------------------------------
  154.        Dim Result1 As Integer() = {Num1 - 1, Num1 - 2, Num1 - 3, Num1 + 1, Num1 + 2, Num1 + 3}
  155.  
  156.        For Index As Integer = 0 To (Result1.Count - 1)
  157.  
  158.            Select Case Result1(Index)
  159.  
  160.                Case Is = 0 ' El valor es 0. esto todavia no me funciona
  161.                    ' Hacer algo con el número 0 aquí. no mostrar el 0
  162.                    '   Result1(Index) = Not 0
  163.  
  164.                Case Is < 0 ' El valor es negativo.
  165.                    ' Lo convierto a positivo si funciona.
  166.                    Result1(Index) = Math.Abs(Result1(Index))
  167.  
  168.            End Select '/ Result1(Index)
  169.  
  170.  
  171.        Next Index
  172.  
  173.        Result1 = Result1.Distinct().ToArray
  174.        Array.Sort(Result1)
  175.  
  176.        '---------------------------------------------------
  177.  
  178.        Result2 = {Num2 + 1, Num2 + 2, Num2 + 3, Num2 - 1, Num2 - 2} _
  179.                  .Distinct().ToArray
  180.        Array.Sort(Result2)
  181.  
  182.        Result3 = {Num3 + 1, Num3 + 2, Num3 + 3, Num3 - 1, Num3 - 2, Num3 - 3} _
  183.                  .Distinct().ToArray
  184.        Array.Sort(Result3)
  185.  
  186.        Result4 = {Num4 + 1, Num4 + 2, Num4 + 3, Num4 - 1, Num4 - 2, Num4 - 3} _
  187.                  .Distinct().ToArray
  188.        Array.Sort(Result4)
  189.  
  190.        Result5 = {Num5 + 1, Num5 + 2, Num5 + 3, Num5 - 1, Num5 - 2, Num5 - 3} _
  191.                  .Distinct().ToArray
  192.        Array.Sort(Result5)
  193.  
  194.        Result6 = {Num6 + 1, Num6 + 2, Num6 + 3, Num6 - 1, Num6 - 2, Num6 - 3} _
  195.                  .Distinct().ToArray
  196.  
  197.        Array.Sort(Result6)
  198.  
  199.        Result7 = {Num7 + 1, Num7 + 2, Num7 + 3, Num7 - 1, Num7 - 2, Num7 - 3} _
  200.                  .Distinct().ToArray
  201.  
  202.        Array.Sort(Result7)
  203.  
  204.        Result8 = {Num8 + 1, Num8 + 2, Num8 + 3, Num8 - 1, Num8 - 2, Num8 - 3} _
  205.                  .Distinct().ToArray
  206.        Array.Sort(Result8)
  207.  
  208.        Result9 = {Num9 + 1, Num9 + 2, Num9 + 3, Num9 - 1, Num9 - 2, Num9 - 3} _
  209.                  .Distinct().ToArray
  210.        Array.Sort(Result9)
  211.  
  212.        Result10 = {Num10 + 1, Num10 + 2, Num10 - 1, Num10 - 2, Num10 - 3} _
  213.                  .Distinct().ToArray
  214.        Array.Sort(Result10)
  215.  
  216.        Result11 = {Num11 + 1, Num11 + 2, Num11 + 3, Num11 - 1, Num11 - 2, Num11 - 3} _
  217.                  .Distinct().ToArray
  218.        Array.Sort(Result11)
  219.  
  220.        Result12 = {Num12 + 1, Num12 + 2, Num12 + 3, Num12 - 1, Num12 - 2, Num12 - 3} _
  221.                  .Distinct().ToArray
  222.        Array.Sort(Result12)
  223.  
  224.        Result13 = {Num13 + 1, Num13 + 2, Num13 + 3, Num13 - 1, Num13 - 2, Num13 - 3} _
  225.                  .Distinct().ToArray
  226.        Array.Sort(Result13)
  227.  
  228.        Result14 = {Num14 + 1, Num14 + 2, Num14 + 3, Num14 - 1, Num14 - 2, Num14 - 3} _
  229.                  .Distinct().ToArray
  230.        Array.Sort(Result14)
  231.  
  232.        Result15 = {Num15 + 1, Num15 + 2, Num15 + 3, Num15 - 1, Num15 - 2, Num15 - 3} _
  233.                  .Distinct().ToArray
  234.        Array.Sort(Result15)
  235.  
  236.        Result16 = {Num16 + 1, Num16 + 2, Num16 + 3, Num16 - 1, Num16 - 2, Num16 - 3} _
  237.                  .Distinct().ToArray
  238.        Array.Sort(Result16)
  239.  
  240.        Result17 = {Num17 + 1, Num17 + 2, Num17 + 3, Num17 - 1, Num17 - 2, Num17 - 3} _
  241.                  .Distinct().ToArray
  242.        Array.Sort(Result17)
  243.  
  244.        Result18 = {Num18 + 1, Num18 + 2, Num18 + 3, Num18 - 1, Num18 - 2, Num18 - 3} _
  245.                  .Distinct().ToArray
  246.        Array.Sort(Result18)
  247.  
  248.        Result19 = {Num19 + 1, Num19 + 2, Num19 + 3, Num19 - 1, Num19 - 2, Num19 - 3} _
  249.                  .Distinct().ToArray
  250.  
  251.        Array.Sort(Result19)
  252.        Result20 = {Num20 + 1, Num20 + 2, Num20 + 3, Num20 - 1, Num20 - 2, Num20 - 3} _
  253.                  .Distinct().ToArray
  254.  
  255.        Array.Sort(Result20)
  256.        ' Elimino duplicados al mismo tiempo que selecciono los números inferiores a MAX.
  257.        Dim Resultss As IEnumerable(Of Integer) =
  258.            (
  259.                From Value As Integer
  260.                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
  261.                Where Value <= MAX
  262.            )
  263.  
  264.        ListBox2.Items.AddRange(Resultss.Cast(Of Object).ToArray)
  265.  
  266.        'funcion unir combis
  267.        FixedValues =
  268.             ((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).
  269.             Distinct.
  270.             Select(Function(Value As Integer)
  271.                        Return If(Value < MAX, Value, Rand.Next(0, MAX))
  272.                    End Function).ToArray
  273.  
  274.        Dim IndexCounter As Integer = FixedValues.First ' 1
  275.        Dim LenCounter As Integer = 0I
  276.  
  277.        Const NumStep As Integer = 3I
  278.        Const NumLen As Integer = 10I
  279.  
  280.        Do Until IndexCounter > FixedValues.Last
  281.  
  282.            Combo = New List(Of Integer)
  283.  
  284.  
  285.            For Num As Integer = IndexCounter To (FixedValues.Count - 1I) Step NumStep
  286.  
  287.                LenCounter += 1I
  288.                Combo.Add(FixedValues(Num - 1I)) 'matrix fuersa
  289.  
  290.                If LenCounter >= NumLen Then
  291.                    Exit For
  292.                End If
  293.  
  294.            Next Num
  295.  
  296.            If LenCounter < NumLen Then
  297.  
  298.                For RandomNum As Integer = 1I To (NumLen - LenCounter)
  299.  
  300.                    Dim n As Integer = Randomizer.Next(RandomValues.First, RandomValues.Last)
  301.  
  302.                    Do Until Not Combo.Contains(n)
  303.                        n = Randomizer.Next(RandomValues.First, RandomValues.Last)
  304.                    Loop
  305.  
  306.                    Combo.Add(n)
  307.  
  308.                Next ' RandomNum
  309.  
  310.            End If ' LenCounter < NumLen
  311.  
  312. #If DEBUG Then ' #Debug
  313.            Debug.WriteLine(String.Join(", ", Combo))
  314.            ' Stop
  315. #End If
  316.            Combo.Sort()
  317.            Combos.Add(Combo)
  318.            IndexCounter += 1I
  319.            LenCounter = 0I
  320.  
  321.        Loop ' IndexCounter >= FixedValues.Last
  322.  
  323.        ' ******** ordenamiento-------------
  324.        '  Dim values As Integer() = (From n As Integer In Combos Order By n Ascending).ToArray
  325.  
  326.        ' ********
  327.        ' Listbox:
  328.        ' ********
  329.        Combos.ForEach(Sub(comb As List(Of Integer))
  330.  
  331.                           ' Convierto la Lista a 'String', le añado los ceros, y añado el string formateado al Listbox.
  332.                           ListBox1.Items.Add(String.Join(", ",
  333.                                                          From value As String In comb
  334.                                                          Select If(value.Length = 1I,
  335.                                                                    value.Insert(0I, "0"c),
  336.                                                                    value)))
  337.                           ListBox1.Sorted = True
  338.  
  339.  
  340.  
  341.                       End Sub)
  342.  
  343.    End Sub
  344.  
  345.  
  346.        ' Application.Exit()
  347.  
  348.    Private Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
  349.        sender.text = System.Text.RegularExpressions.Regex.Replace(sender.text, "\D", "")
  350.  
  351.    End Sub
  352.  
  353.    Private Sub TextBox3_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
  354.        sender.text = System.Text.RegularExpressions.Regex.Replace(sender.text, "\D", "")
  355.    End Sub
  356.  
  357.    Private Sub TextBox4_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
  358.        sender.text = System.Text.RegularExpressions.Regex.Replace(sender.text, "\D", "")
  359.    End Sub
  360.  
  361.    Private Sub TextBox5_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
  362.        sender.text = System.Text.RegularExpressions.Regex.Replace(sender.text, "\D", "")
  363.    End Sub
  364.  
  365.    Private Sub TextBox2_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
  366.        sender.text = System.Text.RegularExpressions.Regex.Replace(sender.text, "\D", "")
  367.    End Sub
  368.  
  369.  
  370.    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  371.  
  372.    End Sub
  373.  
  374.    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
  375.        solonumeros(e)
  376.        If e.KeyChar = ChrW(Keys.Enter) Then
  377.            e.Handled = True
  378.            SendKeys.Send("{TAB}")
  379.        End If
  380.    End Sub
  381.  
  382.    Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
  383.        solonumeros(e)
  384.        If e.KeyChar = ChrW(Keys.Enter) Then
  385.            e.Handled = True
  386.            SendKeys.Send("{TAB}")
  387.        End If
  388.    End Sub
  389.  
  390.    Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
  391.        solonumeros(e)
  392.        If e.KeyChar = ChrW(Keys.Enter) Then
  393.            e.Handled = True
  394.            SendKeys.Send("{TAB}")
  395.        End If
  396.    End Sub
  397.  
  398.    Private Sub TextBox4_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox4.KeyPress
  399.        solonumeros(e)
  400.        If e.KeyChar = ChrW(Keys.Enter) Then
  401.            e.Handled = True
  402.            SendKeys.Send("{TAB}")
  403.        End If
  404.    End Sub
  405.  
  406.    Private Sub TextBox5_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox5.KeyPress
  407.        solonumeros(e)
  408.        If e.KeyChar = ChrW(Keys.Enter) Then
  409.            e.Handled = True
  410.            SendKeys.Send("{TAB}")
  411.        End If
  412.    End Sub
  413.    Private Sub TextBox6_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox6.KeyPress
  414.        solonumeros(e)
  415.        If e.KeyChar = ChrW(Keys.Enter) Then
  416.            e.Handled = True
  417.            SendKeys.Send("{TAB}")
  418.  
  419.        End If
  420.  
  421.    End Sub
  422.    Private Sub TextBox7_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox7.KeyPress
  423.        solonumeros(e)
  424.        If e.KeyChar = ChrW(Keys.Enter) Then
  425.            e.Handled = True
  426.            SendKeys.Send("{TAB}")
  427.  
  428.        End If
  429.  
  430.    End Sub
  431.  
  432.    Private Sub TextBox8_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox8.KeyPress
  433.        solonumeros(e)
  434.        If e.KeyChar = ChrW(Keys.Enter) Then
  435.            e.Handled = True
  436.            SendKeys.Send("{TAB}")
  437.  
  438.        End If
  439.  
  440.    End Sub
  441.  
  442.    Private Sub TextBox9_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox9.KeyPress
  443.        solonumeros(e)
  444.        If e.KeyChar = ChrW(Keys.Enter) Then
  445.            e.Handled = True
  446.            SendKeys.Send("{TAB}")
  447.  
  448.        End If
  449.  
  450.    End Sub
  451.    Private Sub TextBox10_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox10.KeyPress
  452.        solonumeros(e)
  453.        If e.KeyChar = ChrW(Keys.Enter) Then
  454.            e.Handled = True
  455.            SendKeys.Send("{TAB}")
  456.  
  457.        End If
  458.  
  459.    End Sub
  460.  
  461.    Private Sub TextBox11_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox11.KeyPress
  462.        solonumeros(e)
  463.        If e.KeyChar = ChrW(Keys.Enter) Then
  464.            e.Handled = True
  465.            SendKeys.Send("{TAB}")
  466.  
  467.        End If
  468.  
  469.    End Sub
  470.    Private Sub TextBox12_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox12.KeyPress
  471.        solonumeros(e)
  472.        If e.KeyChar = ChrW(Keys.Enter) Then
  473.            e.Handled = True
  474.            SendKeys.Send("{TAB}")
  475.  
  476.        End If
  477.  
  478.    End Sub
  479.    Private Sub TextBox13_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox13.KeyPress
  480.        solonumeros(e)
  481.        If e.KeyChar = ChrW(Keys.Enter) Then
  482.            e.Handled = True
  483.            SendKeys.Send("{TAB}")
  484.  
  485.        End If
  486.  
  487.    End Sub
  488.    Private Sub TextBox14_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox14.KeyPress
  489.        solonumeros(e)
  490.        If e.KeyChar = ChrW(Keys.Enter) Then
  491.            e.Handled = True
  492.            SendKeys.Send("{TAB}")
  493.  
  494.        End If
  495.  
  496.    End Sub
  497.    Private Sub TextBox15_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox15.KeyPress
  498.        solonumeros(e)
  499.        If e.KeyChar = ChrW(Keys.Enter) Then
  500.            e.Handled = True
  501.            SendKeys.Send("{TAB}")
  502.  
  503.        End If
  504.  
  505.    End Sub
  506.    Private Sub TextBox16_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox16.KeyPress
  507.        solonumeros(e)
  508.        If e.KeyChar = ChrW(Keys.Enter) Then
  509.            e.Handled = True
  510.            SendKeys.Send("{TAB}")
  511.  
  512.        End If
  513.  
  514.    End Sub
  515.    Private Sub TextBox17_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox17.KeyPress
  516.        solonumeros(e)
  517.        If e.KeyChar = ChrW(Keys.Enter) Then
  518.            e.Handled = True
  519.            SendKeys.Send("{TAB}")
  520.  
  521.        End If
  522.  
  523.    End Sub
  524.    Private Sub TextBox18_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox18.KeyPress
  525.        solonumeros(e)
  526.        If e.KeyChar = ChrW(Keys.Enter) Then
  527.            e.Handled = True
  528.            SendKeys.Send("{TAB}")
  529.  
  530.        End If
  531.  
  532.    End Sub
  533.    Private Sub TextBox19_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox19.KeyPress
  534.        solonumeros(e)
  535.        If e.KeyChar = ChrW(Keys.Enter) Then
  536.            e.Handled = True
  537.            SendKeys.Send("{TAB}")
  538.  
  539.        End If
  540.  
  541.    End Sub
  542.    Private Sub TextBox20_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox20.KeyPress
  543.        solonumeros(e)
  544.        If e.KeyChar = ChrW(Keys.Enter) Then
  545.            e.Handled = True
  546.            SendKeys.Send("{TAB}")
  547.  
  548.        End If
  549.  
  550.    End Sub
  551.  
  552.    Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  553.        For Each obj As Control In Me.Controls
  554.            If (TypeOf obj Is TextBox) Then
  555.                obj.Text = ""
  556.            End If
  557.            If (TypeOf obj Is GroupBox) Then
  558.                For Each caja As Control In obj.Controls
  559.                    If (TypeOf caja Is TextBox) Then
  560.                        caja.Text = ""
  561.                    End If
  562.                Next
  563.            End If
  564.            ListBox1.Items.Clear()
  565.  
  566.  
  567.        Next
  568.    End Sub
  569.  
  570. End Class
  571.  
  572.  
  573.  
  574.  




En línea

Que tu sabiduria no sea motivo de Humillacion para los demas
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Mis malas combinaciones :(
« Respuesta #42 en: 29 Agosto 2014, 18:16 pm »

Hola pongo el código entero, lo de poner los números en la variable es como difícil sin tener que cortar el código, que como veras hace una serie de cálculos con 20 dígitos que introduzco y saber cuantos números salen de esa ecuación es un poco difícil

ya, el programa hace el cálculo, ¿pero para que pueda buscar el error no puedes ponerme algo así?:

Código:
Dim fixedvalues as integer() = {1,2,3 etc,...}

Si no no se con que números debería probar en el for...

cuando pueda le echo un ojo

saludos
En línea

luis456


Desconectado Desconectado

Mensajes: 548



Ver Perfil
Re: Mis malas combinaciones :(
« Respuesta #43 en: 29 Agosto 2014, 18:56 pm »

Con esta secuencia de numeros me da el error


Código
  1. Dim fixedvalues as integer() = {02, 03, 11, 12, 16, 18, 25, 27, 28, 31,40, 41, 43, 52, 53, 56, 57, 70, 77, 80}  

Luis



[ELEKTRO]: Mañana lo miro con calma luis, lo siento si te hice esperar
« Última modificación: 30 Agosto 2014, 01:59 am por Eleкtro » En línea

Que tu sabiduria no sea motivo de Humillacion para los demas
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Mis malas combinaciones :(
« Respuesta #44 en: 30 Agosto 2014, 20:16 pm »

He probado el For con la secuencia que dijiste y no me da ningún error de tipo " Índice fuera de los límites de la matriz ", así que no le hice ninguna modificación al código, está todo correcto en este código? (fixedvalues, numstep, numlen, IndexCounter):

Código
  1. Public Class Form1
  2.  
  3.    ReadOnly Randomizer As New Random
  4.  
  5.    Private Sub Sumar(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Shown
  6.  
  7.        Dim Combo As List(Of Integer) = Nothing
  8.        Dim Combos As New List(Of List(Of Integer))
  9.  
  10.        Dim fixedvalues As Integer() = {2, 3, 11, 12, 16, 18, 25, 27, 28, 31, 40, 41, 43, 52, 53, 56, 57, 70, 77, 80}
  11.        Dim RandomValues As Integer() = Enumerable.Range(0, 99).ToArray
  12.  
  13.        Dim IndexCounter As Integer = fixedvalues.First ' 1
  14.        Dim LenCounter As Integer = 0I
  15.  
  16.        Const NumStep As Integer = 3I
  17.        Const NumLen As Integer = 10I
  18.  
  19.        Do Until IndexCounter > fixedvalues.Last
  20.  
  21.            Combo = New List(Of Integer)
  22.  
  23.            For Num As Integer = IndexCounter To (fixedvalues.Count - 1I) Step NumStep
  24.  
  25.                LenCounter += 1I
  26.                Combo.Add(fixedvalues(Num - 1I)) 'matrix fuersa
  27.  
  28.                If LenCounter >= NumLen Then
  29.                    Exit For
  30.                End If
  31.  
  32.            Next Num
  33.  
  34.            If LenCounter < NumLen Then
  35.  
  36.                For RandomNum As Integer = 1I To (NumLen - LenCounter)
  37.  
  38.                    Dim n As Integer = Randomizer.Next(RandomValues.First, RandomValues.Last)
  39.  
  40.                    Do Until Not Combo.Contains(n)
  41.                        n = Randomizer.Next(RandomValues.First, RandomValues.Last)
  42.                    Loop
  43.  
  44.                    Combo.Add(n)
  45.  
  46.                Next ' RandomNum
  47.  
  48.            End If ' LenCounter < NumLen
  49.  
  50.            Combo.Sort()
  51.            Combos.Add(Combo)
  52.            IndexCounter += 1I
  53.            LenCounter = 0I
  54.  
  55.        Loop ' IndexCounter >= FixedValues.Last
  56.  
  57.        Combos.ForEach(Sub(comb As List(Of Integer))
  58.  
  59.                           ' Convierto la Lista a 'String', le añado los ceros, y añado el string formateado al Listbox.
  60.                           ListBox1.Items.Add(String.Join(", ",
  61.                                                          From value As String In comb
  62.                                                          Select If(value.Length = 1I,
  63.                                                                    value.Insert(0I, "0"c),
  64.                                                                    value)))
  65.                           ListBox1.Sorted = True
  66.  
  67.  
  68.  
  69.                       End Sub)
  70.  
  71.    End Sub
  72.  
  73. End Class

saludos
« Última modificación: 30 Agosto 2014, 20:19 pm por Eleкtro » En línea

luis456


Desconectado Desconectado

Mensajes: 548



Ver Perfil
Re: Mis malas combinaciones :(
« Respuesta #45 en: 30 Agosto 2014, 21:40 pm »

 :-X :-X :-X :-X :-X :-X :rolleyes: :rolleyes: :rolleyes: :rolleyes:

Vere que pasa sera otra cosa

gracias

Luis
En línea

Que tu sabiduria no sea motivo de Humillacion para los demas
luis456


Desconectado Desconectado

Mensajes: 548



Ver Perfil
Re: Mis malas combinaciones :(
« Respuesta #46 en: 1 Septiembre 2014, 17:44 pm »

Bien lo he probado repasado y parece que ya el error no me lo hace realmente no se como se arreglo jejej,lo que hice fue hacer un nuevo proyecto lo renombre y ahora va bien salvo jjejjj siempre hay un pero,

Como hago para que en las  combinaciones no me salga 00

00 10 25 35 48 49 50 51 70 72 90
00 15 25 38 45 48 49 52 56 70 88

Saludos
Luis
En línea

Que tu sabiduria no sea motivo de Humillacion para los demas
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Mis malas combinaciones :(
« Respuesta #47 en: 1 Septiembre 2014, 19:39 pm »

Como hago para que en las  combinaciones no me salga 00

Código
  1.        Combos.ForEach(Sub(comb As List(Of Integer))
  2.  
  3.                          ' Convierto la Lista a 'String', le añado los ceros, y añado el string formateado al Listbox.
  4.                          ListBox1.Items.Add(String.Join(", ",
  5.                                                         From value As String In comb
  6.                                                         Select If(value.Length = 1I,
  7.                                                                   value.Insert(0I, "0"c),
  8.                                                                   value)))
  9.                          ListBox1.Sorted = True
  10.  
  11.  
  12.  
  13.                      End Sub)

Supongo que te refieres a poner "0" y no "00", entonces:

Código
  1.        Combos.ForEach(Sub(comb As List(Of Integer))
  2.  
  3.                          ' Convierto la Lista a 'String', le añado los ceros, y añado el string formateado al Listbox.
  4.                          ListBox1.Items.Add(String.Join(", ",
  5.                                                         From value As String In comb
  6.                                                         Select If(value.Length = 1I andalso not value.equals("0"),
  7.                                                                   value.Insert(0I, "0"c),
  8.                                                                   value)))
  9.                          ListBox1.Sorted = True
  10.  
  11.  
  12.  
  13.                      End Sub)
« Última modificación: 1 Septiembre 2014, 19:41 pm por Eleкtro » En línea

luis456


Desconectado Desconectado

Mensajes: 548



Ver Perfil
Re: Mis malas combinaciones :(
« Respuesta #48 en: 2 Septiembre 2014, 07:55 am »

Hola

 " Supongo que te refieres a poner "0" y no "00", entonces: "

No me refiero a que no muestre combinaciones que tengan 00 o  0

Luis
En línea

Que tu sabiduria no sea motivo de Humillacion para los demas
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Mis malas combinaciones :(
« Respuesta #49 en: 2 Septiembre 2014, 15:34 pm »

¿y entonces que quieres mostrar en su lugar?, no soy adivino, luis.

pero de todas formas creo que eso ya puedes hacerlo tu solito

saludos!
En línea

Páginas: 1 2 3 4 [5] 6 Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Instrucciones malas :P
Ingeniería Inversa
x64core 3 2,884 Último mensaje 7 Diciembre 2011, 16:45 pm
por Flamer
Combinaciones con subrangos
.NET (C#, VB.NET, ASP)
luis456 1 1,660 Último mensaje 25 Noviembre 2014, 12:20 pm
por Eleкtro
Usuarios de Yelp bombardean pizzería antigay con malas reseñas « 1 2 3 4 5 »
Noticias
wolfbcn 47 10,878 Último mensaje 5 Abril 2015, 03:10 am
por MinusFour
Mas combinaciones condicionadas
.NET (C#, VB.NET, ASP)
luis456 0 1,309 Último mensaje 5 Abril 2016, 11:42 am
por luis456
Vulnerabilidades por malas practicas streaming
Bugs y Exploits
neftali.evando88 5 7,099 Último mensaje 23 Octubre 2020, 20:44 pm
por MCKSys Argentina
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines