范例 8.1
在这个例子中,您可以根据考试成绩而决定它的等级。
Dim grade As String
Private Sub Compute_Click( )
grade=txtgrade.Text
Select Case grade
Case "A"
result.Caption="特优"
Case "A-"
result.Caption="优等"
Case "B"
result.Caption="中等"
Case "C"
result.Caption="及格"
Case Else
result.Caption="不及格"
End Select
End Sub
范例 8.2
Dim mark As Single
Private Sub Compute_Click()
'Examination Marks
mark = mrk.Text
Select Case mark
Case Is >= 85
comment.Caption = "特优"
Case Is >= 70
comment.Caption = "优等"
Case Is >= 60
comment.Caption = "中等"
Case Is >= 50
comment.Caption = "及格"
Case Else
comment.Caption = "不及格"
End Select
End Sub