Previous topicNext topic
Help > 开发指南 > 编程基础 > VB编程基础 > 决策 >
嵌套Select Case语句

嵌套的Select Case语句可以将select语句作为外部select语句的语句序列的一部分。 即使内部和外部选择的情况常数包含公共值,也不会出现冲突。


示例:

Dim a As Integer = 100
Dim b As Integer = 200
Select a
    Case 100
        Proj.MsgDebug.Add("This is part of outer case ")
        Select Case b
            Case 200
                Proj.MsgDebug.Add("This is part of inner case ")
        End Select
End Select
Proj.MsgDebug.Add("Exact value of a is : {0}", a)
Proj.MsgDebug.Add("Exact value of b is : {0}", b)

'返回结果:This Is part Of outer Case
'返回结果:This Is part Of inner Case
'返回结果:Exact value Of a Is : 100
'返回结果:Exact value Of b Is : 200