Manual de Visual Basic Intermedio

 

  Lección: 11

 

Capítulo: Ejercicio 11: Calificaciones

 

 

Crea un formulario con ocho etiquetas, nueve cajas de texto, tres botones ye escribe el siguiente código:

 

El botón Salir

 

Private Sub Command3_Click()

 

Unload Me

 

End

 

End Sub

 

El botón Limpiar

 

Private Sub Command2_Click()

 

Text1 = ""

 

Text2 = ""

 

Text3 = ""

 

Text4 = ""

 

Text5 = ""

 

Text6 = ""

 

Text7 = ""

 

Text8 = ""

 

Text9 = ""

 

Text1.SetFocus

 

End Sub

 

El botón 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

 

   Volver al índice!