运行代码时,我最简单的if语句可以计算出一个人是否通过了考试,结果总是失败。
Public Class Form1
Dim EnglishMark As Single
Dim ScienceMark As Single
Dim MathsMark As Single
Dim AverageMark As Single
Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
EnglishMark = Val(txtEnglish.Text)
ScienceMark = Val(txtScience.Text)
MathsMark = Val(txtMaths.Text)
AverageMark = (EnglishMark + ScienceMark + MathsMark) / 3 / 100
If (AverageMark >= 50) Then
lblDisplay.Text = "You Passed Well Done" & Format(AverageMark, "Percent")
Else
lblDisplay.Text = "You Failed Try Again" & Format(AverageMark, "Percent")
End If
End Sub
End Class
谢谢