Manual de Visual Basic Intermedio
Lección: 8
Capítulo: Ejercicio 8: Registro de Cursos
Crea un formulario con cuatro marcos, seis etiquetas, cinco
cajas de texto, un cuadro combinado, dos cajas de lista, cuatro botones y
escribe el siguiente
código:
Private Sub
Form_Load()
List1.AddItem
"Intro. a Sistemas"
List1.AddItem
"Windows"
List1.AddItem
"MS Word"
List1.AddItem
"MS Excel"
List1.AddItem
"MS PowerPoint"
List1.AddItem
"MS Access"
List1.AddItem
"Soporte Técnico"
List1.AddItem
"Redes"
List1.AddItem
"MS Visual Basic"
List1.AddItem
"Internet"
List2.AddItem
"Chihuahua"
List2.AddItem
"Campeche"
List2.AddItem
"Veracruz"
List2.AddItem "Colima"
List2.AddItem "Yucatán"
List2.AddItem "Sonora"
List2.AddItem "Sinaloa"
List2.AddItem "Puebla"
List2.AddItem "Tabasco"
List2.AddItem
"Zacatecas"
Combo1.AddItem
"Masculino"
Combo1.AddItem
"Femenino"
End Sub
Private Sub
Form_Unload(Cancel As Integer)
If MsgBox("¿Estás
Seguro de Querer Cerrar el Programa?", vbQuestion
+ vbYesNo, "¿Oye qué pasa contigo?") = vbYes Then
End
Else
Cancel = True
End If
End Sub
Private Sub
List1_Click()
Text1 = List1
End Sub
Private Sub
List2_Click()
Text5 = List2
End Sub
El botón Guardar
Private Sub
Command1_Click()
List1.Enabled = False
List2.Enabled = False
Text1.Locked = True
Text2.Locked = True
Combo1.Locked = True
Text4.Locked = True
Text5.Locked = True
MsgBox "Este Alumno ha sido
Matriculado", vbInformation, "Mensaje
Importante"
End Sub
El botón Limpiar
Private Sub
Command2_Click()
List1.Enabled = True
List2.Enabled = True
Text1.Locked = False
Text2.Locked = False
Text3.Locked = False
Combo1.Locked = False
Text4.Locked = False
Text5.Locked = False
Text1 = ""
Text2 = ""
Text3 = ""
Combo1 = ""
Text4 = ""
Text5 = ""
Text1.SetFocus
End Sub
El botón Cancelar
Private Sub
Command3_Click()
If MsgBox("Deseas
Cancelar Algún Dato?", vbQuestion + vbYesNo, "Aviso Muy Importante") = vbYes Then
List1.Enabled = True
List2.Enabled = True
Text1.Locked = False
Text2.Locked = False
Text3.Locked = False
Combo1.Locked = False
Text4.Locked = False
Text5.Locked = False
End If
End Sub
El botón Salir
Private Sub
Command4_Click()
Unload Me
End
End Sub