Sei sulla pagina 1di 8

Captulo 3:

Calcular la edad

Crea un formulario con dos etiquetas, dos cajas de texto y tres botones,
escribe el siguiente cdigo:
El botn Calcular la Edad
Private Sub Command1_Click()
Dim fecnac As Date, edad As Integer
fecnac = CDate(Text1)
edad = CInt((Date - fecnac) / 365)
Text2 = Str(edad) & " aos"
End Sub
El botn Nuevo Clculo
Private Sub Command2_Click()
Text1 = ""
Text2 = ""
Text1.SetFocus
End Sub
El botn Salir
Private Sub Command3_Click()

Unload Me
End
End Sub

Captulo 5:
Ejercicio 5: Fecha Escrita

Crea un formulario con cinco etiquetas, tres cajas de texto, un marco,


tres botones y escribe el siguiente cdigo:
El botn Convertir
Private Sub Command1_Click()
Dim cadmes As String, mes As Integer
mes = Val(Text2)
Select Case mes
Case 1: cadmes = "Enero"
Case 2: cadmes = "Febrero"
Case 3: cadmes = "Marzo"
Case 4: cadmes = "Abril"
Case 5: cadmes = "Mayo"
Case 6: cadmes = "Junio"

Case 7: cadmes = "Julio"


Case 8: cadmes = "Agosto"
Case 9: cadmes = "Septiembre"
Case 10: cadmes = "Octubre"
Case 11: cadmes = "Noviembre"
Case 12: cadmes = "Diciembre"
Case Else
MsgBox "Revsalos Por Favor", vbCritical, "Hay un Error en los
Datos...!!!"
Call Command2_Click
Exit Sub
End Select
Label4 = Text1 & " de " & cadmes & " de " & Text3
End Sub
El botn Limpiar
Private Sub Command2_Click()
Text1 = ""
Text2 = ""
Text3 = ""
Text1.SetFocus
End Sub
El botn Salir
Private Sub Command3_Click()
If MsgBox("Ya Quieres Salir del Programa?", vbQuestion + vbYesNo,
"Tengo una Pregunta para Ti") = vbYes Then

End
Else: Call Command2_Click
End If
End Sub

Captulo 11:
Ejercicio 11: Calificaciones

Crea un formulario con ocho etiquetas, nueve cajas de texto, tres


botones ye escribe el siguiente cdigo:
El botn Salir
Private Sub Command3_Click()
Unload Me
End
End Sub
El botn Limpiar
Private Sub Command2_Click()
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""

Text5 = ""
Text6 = ""
Text7 = ""
Text8 = ""
Text9 = ""
Text1.SetFocus
End Sub
El botn Prom. Gral. Redondeado
Private Sub Command1_Click()
Dim n1 As Double, n2 As Double, n3 As Double, n4 As Double, n5 As
Double, n6 As Double
Dim promedio As Integer
n1 = Val(Text2): n2 = Val(Text3)
n3 = Val(Text4): n4 = Val(Text5)
n5 = Val(Text6): n6 = Val(Text7)
promedio = ((n1 + n2 + n3 + n4 + n5 + n6) / 6)
Text8 = Str(promedio)
If promedio >= 9.5 Then
Text9 = "Excelente"
End If
If promedio >= 9 And promedio < 9.5 Then
Text9 = "Muy Bien"
End If
If promedio >= 8.5 And promedio < 9 Then
Text9 = "Bien"

End If
If promedio >= 8 And promedio < 8.5 Then
Text9 = "Regular"
End If
If promedio < 8 Then
Text9 = "Mal"
End If
End Sub

Captulo 12:
Ejercicio 12: Impresin

Crea un formulario con seis etiquetas, seis cajas de texto, dos botones y escribe
el siguiente cdigo:
El botn Limpiar
Private Sub Command2_Click()
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""

Text6 = ""
Text1.SetFocus
End Sub
El botn Imprimir
Private Sub Command1_Click()
Printer.Orientation = 1
Printer.FontSize = 12
Printer.Print
Printer.Print
Printer.Print
Printer.Print Tab(15); Label1.Caption; Tab(30); Text1.Text
Printer.Print
Printer.Print
Printer.Print Tab(15); Label2.Caption; Tab(30); Text2.Text
Printer.Print
Printer.Print
Printer.Print Tab(15); Label3.Caption; Tab(30); Text3.Text
Printer.Print
Printer.Print
Printer.Print Tab(15); Label4.Caption; Tab(30); Text4.Text
Printer.Print
Printer.Print
Printer.Print Tab(15); Label5.Caption; Tab(30); Text5.Text
Printer.Print

Printer.Print
Printer.Print Tab(15); Label6.Caption; Tab(30); Text6.Text
Printer.EndDoc
End Sub

Potrebbero piacerti anche