Tiemblo cada ves que veo que Elektro me responde jejejej,bueno aca va
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(), Result4 As Int32()
Private _textBox As Object
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
' trial-----------------------------
Private Shadows Sub Load() Handles MyBase.Load
My.Settings.contador += 1
checar()
End Sub
Sub checar()
If My.Settings.contador >= 2500 Then
MsgBox("Por motivos de seguridad este programa no se activara hasta que me la gana jejeje")
'Application.Exit()
End If
End Sub
'---------------------
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 Sub FrmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.ControlBox = False ' Elimino todos los controles del formulario
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
ReadOnly Property Num4 As Int32
Get
Return CInt(TextBox4.Text)
End Get
End Property
Private Sub Sumar(ByVal sender As Object, ByVal e As EventArgs) _
Handles Button1.Click
Dim TextBoxCount As Short = -1
TextBoxes = {TextBox5, TextBox6, TextBox7, TextBox8, TextBox9, TextBox10, TextBox11, TextBox12, TextBox13, TextBox14, TextBox15, TextBox16, TextBox17, TextBox18, TextBox19, TextBox20, TextBox21, TextBox22, TextBox23, TextBox24, TextBox25, TextBox26, TextBox27, TextBox28, TextBox29, TextBox29, TextBox30, TextBox31, TextBox32, TextBox33, TextBox34, TextBox35, TextBox36, TextBox37, TextBox38, TextBox39, TextBox40, TextBox41, TextBox42}
Result1 = {Num1 + 10, Num1 + 20, Num1 + 30} _
.Distinct().ToArray ' Elimino duplicados
Result2 = {Num2 + 10, Num2 + 20, Num2 + 30} _
.Distinct().ToArray ' Elimino duplicados
Result3 = {Num3 + 10, Num3 + 20, Num3 + 30} _
.Distinct().ToArray ' Elimino duplicados
Result4 = {Num4 + 10, Num4 + 20, Num4 + 30} _
.Distinct().ToArray ' Elimino duplicados
Array.Sort(Result1) : Array.Sort(Result2) : Array.Sort(Result3) : Array.Sort(Result4) : Array.Sort(Result5) : Array.Sort(Result6) ' Ordeno los Items
' ----------------------------------------------------------------------------
' aca que no salgan repetidos en las lineas -------------------------------------
' Concateno todos los Arrays (esto es algo opcional, simplemente para hacerlo de una en este ejemplo)
Dim Results As IEnumerable(Of Integer) =
Result1.Concat(Result2).Concat(Result3).Concat(Result4)
For X As Integer = 0 To Results.Count - 1
TextBoxCount += 1
Select Case Results.Where(Function(n) n = Results(X)).Skip(1).Any
Case False ' El número no está repetido en ninguna "linea"
' Así que colocamos el número en el Textbox
TextBox(TextBoxCount).Text = Convert.ToString(Results(X))
Case True ' El número está repetido en alguna de las "lineas"
' Así que haces lo que quieras con el Número/Textbox
MsgBox(Results(X))
TextBox(TextBoxCount).Text = -1.ToString
End Select
Next X
' -----------------------------------------------------------------------
' aca vamos con el rango
For Each Number As Int32 In Result1
TextBoxCount += 1
TextBoxes(TextBoxCount).Text = Number
Next
' -----------------------------------------
For Each Number As Int32 In Result2
TextBoxCount += 1
TextBoxes(TextBoxCount).Text = Number
Next
' -----------------------------------------
For Each Number As Int32 In Result3
TextBoxCount += 1
If Not Number > maximum Then
TextBoxes(TextBoxCount).Text = CStr(Number)
Else
TextBoxes(TextBoxCount).Text = CStr(maximum)
End If
Next Number
' -----------------------------------------
For Each Number As Int32 In Result4
TextBoxCount += 1
If Not Number > maximum Then
TextBoxes(TextBoxCount).Text = CStr(Number)
Else
TextBoxes(TextBoxCount).Text = CStr(maximum)
End If
Next Number
' -----------------------------------------
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
' limpiar texboxes
Private Sub Button2_Click(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
Next
End Sub
Private Sub TextBox7_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
' solo numeros sin letras ni signos raros
sender.text = System.Text.RegularExpressions.Regex.Replace(sender.text, "\D", "")
End Sub
Private Sub TextBox8_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
sender.text = System.Text.RegularExpressions.Regex.Replace(sender.text, "\D", "")
End Sub
Private Sub TextBox9_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
sender.text = System.Text.RegularExpressions.Regex.Replace(sender.text, "\D", "")
End Sub
Private Sub TextBox25_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox9.TextChanged, TextBox8.TextChanged, TextBox7.TextChanged, TextBox30.TextChanged, TextBox29.TextChanged, TextBox28.TextChanged, TextBox27.TextChanged, TextBox26.TextChanged, TextBox25.TextChanged, TextBox24.TextChanged, TextBox23.TextChanged, TextBox22.TextChanged, TextBox21.TextChanged, TextBox20.TextChanged, TextBox19.TextChanged, TextBox18.TextChanged, TextBox17.TextChanged, TextBox16.TextChanged, TextBox15.TextChanged, TextBox14.TextChanged, TextBox13.TextChanged, TextBox12.TextChanged, TextBox11.TextChanged, TextBox10.TextChanged
sender.text = System.Text.RegularExpressions.Regex.Replace(sender.text, "\D", "")
End Sub
Private Sub TextBox31_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox36.TextChanged, TextBox35.TextChanged, TextBox34.TextChanged, TextBox33.TextChanged, TextBox32.TextChanged, TextBox31.TextChanged
sender.text = System.Text.RegularExpressions.Regex.Replace(sender.text, "\D", "")
End Sub
Private Sub TextBox6_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox4.KeyPress, TextBox3.KeyPress, TextBox2.KeyPress, TextBox1.KeyPress
Button1.Enabled = ((TextBox1.TextLength > 0) And (TextBox2.TextLength > 0) And (TextBox3.TextLength > 0) And (TextBox4.TextLength > 0) ))
solonumeros(e)
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
End Class]