Hola Elektro
Me decante por la segunda propuesta
Con un TextBox corriente puedes hacerlo de la siguiente manera:
Private Sub TextBox1_Keypress(ByVal sender As Object, e As KeyPressEventArgs) Handles TextBox1.KeyPress
e.Handled = Not Char.IsNumber(e.KeyChar)
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As Object, e As EventArgs) Handles TextBox1.TextChanged
Dim ctrl As TextBox = DirectCast(sender, TextBox)
If CInt(ctrl.Text) > 45 Then
ctrl.Text = "45"
End If
End Sub
[/quote]
Pero claro siempre hay un pero jejje
error
La conversión de la cadena "" en el tipo 'Integer' no es válida.
Bien te enseño como tengo esto montado
Private Sub TextBox6_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox6.KeyPress, TextBox5.KeyPress, 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) And (TextBox5.TextLength > 0) And (TextBox6.TextLength > 0))
'And (TextBox7.TextLength > 0))
solonumeros(e)
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
puse tu código
de esta forma y si retrocede a 45 si pongo un numero mayor pero me salta el error
Private Sub TextBox6_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox6.KeyPress, TextBox5.KeyPress, 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) And (TextBox5.TextLength > 0) And (TextBox6.TextLength > 0))
'And (TextBox7.TextLength > 0))
e.Handled = Not Char.IsNumber(e.KeyChar)
solonumeros(e)
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
Private Sub TextBox6_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TextBox6.TextChanged
Dim ctrl As TextBox = DirectCast(sender, TextBox)
If CInt(ctrl.Text) > 45 Then
ctrl.Text = "45"
End If
End Sub
Luis