Skip to content

Instantly share code, notes, and snippets.

@naranjja
Created April 23, 2015 16:55
Show Gist options
  • Save naranjja/3e04ba20d600635ffa43 to your computer and use it in GitHub Desktop.
Save naranjja/3e04ba20d600635ffa43 to your computer and use it in GitHub Desktop.
'Esta versión usa formularios
'Textboxes para las notas, que se convierten a double con Val(textbox.Text)
Dim notaMin As Single
Dim promedio As Single
If Val(nota1.Text) < 0 Or Val(nota1.Text) > 20 Then
nota1.Text = ""
Error1.Caption = "(!)"
Else: Error1.Caption = ""
End If
notaMin = Val(nota1.Text)
If Val(nota2.Text) < 0 Or Val(nota2.Text) > 20 Then
nota2.Text = ""
Error2.Caption = "(!)"
Else: Error2.Caption = ""
End If
If Val(nota2.Text) < notaMin Then notaMin = Val(nota2.Text)
If Val(nota3.Text) < 0 Or Val(nota3.Text) > 20 Then
nota3.Text = ""
Error3.Caption = "(!)"
Else: Error3.Caption = ""
End If
If Val(nota3.Text) < notaMin Then notaMin = Val(nota3.Text)
If Val(nota4.Text) < 0 Or Val(nota4.Text) > 20 Then
nota4.Text = ""
Error4.Caption = "(!)"
Else: Error4.Caption = ""
End If
If Val(nota4.Text) < notaMin Then notaMin = Val(nota4.Text)
promedio = (Val(nota1.Text) + Val(nota2.Text) + Val(nota3.Text) + Val(nota4.Text) - notaMin) / 3
Resultado.Caption = "El promedio es " & promedio & "."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment