等级应用

时间:2016-06-08 09:09:51

标签: vb.net switch-statement

Select Case form_Login.FF_CorLev_CMB.SelectedIndex
                Case 1
                Case "U"
                    grade_Score = sub_Grade < 420
                    MsgBox("Not enough points")
                Case "P"
                    grade_Score = sub_Grade >= 420 < 460
                    form_Cert.TF_usrGrade_Text.Text = "P"
                Case "M"
                    grade_Score = sub_Grade > 460 < 500
                    form_Cert.TF_usrGrade_Text.Text = "M"
                Case "D"
                    grade_Score = sub_Grade >= 500 < 520
                    form_Cert.TF_usrGrade_Text.Text = "D"
            End Select
    end select

我有4个课程级别,案例1,2 ......在其中我需要区分用户输入的等级,我怎么能有两个选择案例陈述呢?

1 个答案:

答案 0 :(得分:0)

您可以在Select语句中嵌套Select语句,如下所示:

Select Case form_Login.FF_CorLev_CMB.SelectedIndex
       Case 1
           Select Case SomeParameterHereRegardingTheGrade
                  Case "U"
                      grade_Score = sub_Grade < 420
                      MsgBox("Not enough points")
                  Case "P"
                      grade_Score = sub_Grade >= 420 < 460
                      form_Cert.TF_usrGrade_Text.Text = "P"
                  Case "M"
                      grade_Score = sub_Grade > 460 < 500
                      form_Cert.TF_usrGrade_Text.Text = "M"
                  Case "D"
                       grade_Score = sub_Grade >= 500 < 520
                       form_Cert.TF_usrGrade_Text.Text = "D"
             End Select
         Case 2
           Select Case SomeParameterHereRegardingTheGrade
                  Case "U"
                      grade_Score = sub_Grade < 420
                      MsgBox("Not enough points")
                  Case "P"
                      grade_Score = sub_Grade >= 420 < 460
                      form_Cert.TF_usrGrade_Text.Text = "P"
                  Case "M"
                      grade_Score = sub_Grade > 460 < 500
                      form_Cert.TF_usrGrade_Text.Text = "M"
                  Case "D"
                      grade_Score = sub_Grade >= 500 < 520
                      form_Cert.TF_usrGrade_Text.Text = "D"
               End Select           
     End select