Vb.net-nested-select-case-statements

提供:Dev Guides
2020年6月23日 (火) 07:16時点におけるMaintenance script (トーク | 投稿記録)による版 (Imported from text file)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先:案内検索

VB.Net-ネストされた選択ケースステートメント

外部のselectステートメントのステートメントシーケンスの一部としてselectステートメントを持つことができます。 内部選択と外部選択のケース定数に共通の値が含まれていても、競合は発生しません。

Module decisions
   Sub Main()
      'local variable definition
      Dim a As Integer = 100
      Dim b As Integer = 200
      Select a
         Case 100
            Console.WriteLine("This is part of outer case ")
            Select Case b
               Case 200
                  Console.WriteLine("This is part of inner case ")
            End Select
         End Select
      Console.WriteLine("Exact value of a is : {0}", a)
      Console.WriteLine("Exact value of b is : {0}", b)
      Console.ReadLine()
   End Sub
End Module

上記のコードをコンパイルして実行すると、次の結果が生成されます-

This is part of outer case
This is part of inner case
Exact value of a is : 100
Exact value of b is : 200