简单的if语句逻辑返回错误的值

时间:2018-08-31 10:39:58

标签: vb.net

运行代码时,我最简单的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

谢谢

0 个答案:

没有答案