ESTO VA EN UN MODULO
- Para verificar que las cajas de texto no esten vacías.
If nombre.Text = "" Then
MsgBox("Ingresar datos", MsgBoxStyle.Information, "aaaa")
nombre.Select()
Return False
Else
Return True
End If
End Function
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
nombre.Select()
Return False
Else
Return True
End If
End Function
- Para verificar que las solo se ingresen letras
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
- Para que se centre el Formulario.
If ctrl.Parent Is Nothing Then Return
With ctrl
.Top = (.Parent.ClientSize.Height - .Height) \ 2
.Left = (.Parent.ClientSize.Width - .Width) \ 2
End With
End Sub
Public Sub presiona_enter(ByVal e, ByVal boton)
If e.KeyCode = Keys.Enter Then boton.Select()
End Sub
- Para ingreso de solo numeros.
If InStr(1, "0123456789" & Chr(8), e.KeyChar) = 0 Then
e.KeyChar = ""
End If
End Sub
EN EL FORMULARIO
- valida la caja de texto en este caso denominada Tx_siglasTextBox
- En el evento Keypress
sololetras(e)
End Sub
- En el evento KeyUp para pasar la caja de texto siguiente
'donde esta codinternoTextBox es la caja de texto siguiente que va a tomar el foco.
presiona_enter(e, Tx_codinternoTextBox)
End Sub
No hay comentarios:
Publicar un comentario