这是关于大学录取的代码,但不会运行。
Public Class College_Admission
Private Sub btnResult_Click(sender As Object, e As EventArgs) Handles btnResult.Click
Dim score, rank As Integer
score = txtScore.Text
rank = txtRank.Text
Select Case score And rank
Case Is >= 90 and >= 25
lblResult.Text = "Congratulation, you can apply for this college!"
Case Is >= 89 and >= 50
lblResult.Text = "Congratulation, you can apply for this college!"
Case Is >= 70 and >= 75
lblResult.Text = "Congratulation, you can apply for this college!"
Case Else
lblResult.Text = "Sorry, you can not apply this college."
End Select
End Sub
End Class
此代码有什么问题?
答案 0 :(得分:2)
请勿使用Select。因为您有两个要检查的条件,所以它不起作用。就这样做:
If (score >= 90 And rank >= 25) Or (score >= 89 And rank >= 50) Or (score >= 70 And rank >= 75) Then
lblResult.Text = "Congratulations, you can apply to this college!"
Else
lblResult.Text = "Sorry, you cannot apply to this college."
End If