Visual Basic 嵌套 Select Case 语句

可以将 select 语句作为外部 select 语句的语句序列的一部分。即使内部和外部选择的情况常量包含共同的值,也不会产生冲突。


实例

  1. Module decisions
  2. Sub Main()
  3. 'local variable definition
  4. Dim a As Integer = 100
  5. Dim b As Integer = 200
  6. Select a
  7. Case 100
  8. Console.WriteLine("This is part of outer case ")
  9. Select Case b
  10. Case 200
  11. Console.WriteLine("This is part of inner case ")
  12. End Select
  13. End Select
  14. Console.WriteLine("Exact value of a is : {0}", a)
  15. Console.WriteLine("Exact value of b is : {0}", b)
  16. Console.ReadLine()
  17. End Sub
  18. End Module

结果如下:

  1. This is part of outer case
  2. This is part of inner case
  3. Exact value of a is : 100
  4. Exact value of b is : 200

分类导航