1. Haga clic AQUI para descargar la Base de Datos BDCOLEGIO1104
2. Modifique el formulario de la clase pasada que queda asi:
3. Modifique la configuración del Adodc1 para enlazarlo con la base de datos BDCOLEGIO1104
4. Cambie el nombre a los botones por NUEVO, GUARDAR y SALIR
5. Cambie el nombre a las cajas de texto por: Nombres, Apellidos,correo, Lugar_nacimiento.
6. Seleccione el siguiente texto y péguelo en la ventana de código de Visual Basic:
Private Sub Form_Load()
inhabilitarcajas
inhabilitarcombos
inhabilitardtpicker
habilitarbotones
End Sub
Private Sub LUGAR_NACIMIENTO_GotFocus()
If CORREO.Text = Empty Then
MsgBox "No has Digitado el correo del docente"
CORREO.SetFocus
End If
End Sub
Private Sub NUEVO_Click()
habilitarcajas
habilitarcombos
habilitardtpicker
inhabilitarbotones
GUARDAR.Enabled = True
DOCUMENTO.SetFocus
Adodc1.Recordset.AddNew
End Sub
Private Sub GUARDAR_Click()
Adodc1.Recordset.Update
habilitarbotones
GUARDAR.Enabled = False
inhabilitarcajas
inhabilitarcombos
inhabilitardtpicker
End Sub
Private Sub inhabilitarcajas()
Dim n As Integer
For n = 0 To Controls.Count - 1
If TypeOf Controls(n) Is TextBox Then
Controls(n).Enabled = False
End If
Next n
End Sub
Private Sub habilitarcajas()
Dim n As Integer
For n = 0 To Controls.Count - 1
If TypeOf Controls(n) Is TextBox Then
Controls(n).Enabled = True
End If
Next n
End Sub
Private Sub inhabilitarbotones()
Dim n As Integer
For n = 0 To Controls.Count - 1
If TypeOf Controls(n) Is CommandButton Then
Controls(n).Enabled = False
End If
Next n
End Sub
Private Sub habilitarbotones()
Dim n As Integer
For n = 0 To Controls.Count - 1
If TypeOf Controls(n) Is CommandButton Then
Controls(n).Enabled = True
End If
Next n
End Sub
Private Sub habilitarcombos()
Dim n As Integer
For n = 0 To Controls.Count - 1
If TypeOf Controls(n) Is ComboBox Then
Controls(n).Enabled = True
End If
Next n
End Sub
Private Sub inhabilitarcombos()
Dim n As Integer
For n = 0 To Controls.Count - 1
If TypeOf Controls(n) Is ComboBox Then
Controls(n).Enabled = False
End If
Next n
End Sub
Private Sub habilitardtpicker()
Dim n As Integer
For n = 0 To Controls.Count - 1
If TypeOf Controls(n) Is DTPicker Then
Controls(n).Enabled = True
End If
Next n
End Sub
Private Sub inhabilitardtpicker()
Dim n As Integer
For n = 0 To Controls.Count - 1
If TypeOf Controls(n) Is DTPicker Then
Controls(n).Enabled = False
End If
Next n
End Sub
Private Sub Combo1_gotfocus()
If APELLIDOS.Text = Empty Then
MsgBox "No has digitado los Apellidos del Docente."
APELLIDOS.SetFocus
End If
End Sub
Private Sub SALIR_Click()
End
End Sub
Private Sub correo_GotFocus()
If Combo1.Text = Empty Then
MsgBox "No has seleccionado el Genero"
Combo1.SetFocus
End If
End Sub
Private Sub documento_KeyPress(KeyAscii As Integer)
KeyAscii = SoloNumeros(KeyAscii, Len(DOCUMENTO.Text), 10, DOCUMENTO.SelLength)
End Sub
Private Sub nombres_gotFocus()
If DOCUMENTO.Text = Empty Then
MsgBox "No has digitado el número del Documento."
DOCUMENTO.SetFocus
End If
End Sub
Private Sub apellidos_gotFocus()
If NOMBRES.Text = Empty Then
MsgBox "No has digitado el Nombre del docente."
NOMBRES.SetFocus
End If
End Sub
Private Sub DTPicker1_GotFocus()
If LUGAR_NACIMIENTO.Text = Empty Then
MsgBox "No has digitado ciudad de nacimiento del Docente"
LUGAR_NACIMIENTO.SetFocus
End If
End Sub
Function SoloNumeros(ByVal KeyAscii As Integer, ByVal Largo As Integer, ByVal LargoPermitido As Integer, ByVal SelStr As Integer) As Integer
' Intercepta un codigo ASCII recibido admitiendo solamente
' caracteres numéricos, además:
' deja pasar sin afectar si recibe tecla de borrado o return
If InStr("0123456789", Chr(KeyAscii)) = 0 Then
SoloNumeros = 0
Else
SoloNumeros = KeyAscii
End If
' teclas especiales permitidas
If SoloNumeros <> 0 Then
If (Largo + 1) > LargoPermitido And SelStr = 0 Then
SoloNumeros = 0
End If
End If
If KeyAscii = 8 Then SoloNumeros = KeyAscii ' borrado atras
If KeyAscii = 13 Then SoloNumeros = KeyAscii ' return
End Function
No hay comentarios:
Publicar un comentario
No dejes de comentar!!!