Inicio
> HERRAMIENTAS > VALIDAR TEXTBOX
VALIDAR TEXTBOX
Cuando uno empieza a rellenar datos a una caja de texto a veces nos vemos en la problemática de buscar la manera de validar los mismos es decir ..! como hago para que mi caja de texto solo admita numeros, letras, caracteres especiales, que admita solo algunas letras, etc
bueno si mas preámbulo los explicare.:
Textbox que admite solo letras
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If Char.IsLetter(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
Textbox que admite solo números
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If InStr(1, "0123456789,-" & Chr(8), e.KeyChar) = 0 Then e.KeyChar = "" End If End Sub
Pasar de un textbox a otro al presionar Enter
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress 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 If e.KeyChar = ChrW(Keys.Enter) Then e.Handled = True SendKeys.Send("{TAB}") End If End Sub
Borrar los todos los textbox’s de un formulario
Private Sub Limpiar_Cajas(ByVal f As Form) For Each c As Control In f.Controls If TypeOf c Is TextBox Then c.Text = "" End If Next End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Call Limpiar_Cajas(Me) End Sub
para descargar el proyecto :
Categorías: HERRAMIENTAS
Comentarios (0)
Trackbacks (3)
Deja un comentario
Trackback
-
May 12, 2016 a las 7:13 pmokanagan valley population
-
septiembre 14, 2022 a las 8:29 pmETH
-
noviembre 25, 2023 a las 2:06 pmvibs.me