ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

VB.Net program to demonstrate the nested 'select case'

Here, we are going to demonstrate the nested 'select case' in VB.Net.
Submitted by Nidhi, on December 03, 2020

Here, we will define select case inside the case, which is known as nested 'select case'.

Program/Source Code:

The source code to demonstrate the nested "select case" is given below. The given program is compiled and executed successfully.

'VB.Net program to demonstrate the 
'nested "select case"

Module Module1

    Sub Main()
        Dim choice1 As Integer = 2
        Dim choice2 As Single = 2.2

        Select Case choice1
            Case 1
                Select Case choice2
                    Case 1.1
                        Console.WriteLine("Option 1.1")
                    Case 1.2
                        Console.WriteLine("Option 1.2")
                    Case 1.3
                        Console.WriteLine("Option 1.3")
                End Select
            Case 2
                Select Case choice2
                    Case 2.1
                        Console.WriteLine("Option 2.1")
                    Case 2.2
                        Console.WriteLine("Option 2.2")
                    Case 2.3
                        Console.WriteLine("Option 2.3")
                End Select
            Case 3
                Select Case choice2
                    Case 3.1
                        Console.WriteLine("Option 3.1")
                    Case 3.2
                        Console.WriteLine("Option 3.2")
                    Case 2.3
                        Console.WriteLine("Option 3.3")
                End Select
            Case Else
                Console.WriteLine("Invalid choice")
        End Select
    End Sub
    
End Module

Output:

Option 2.2
Press any key to continue . . .

Explanation:

In the above program, we created a module Module1 that contains a Main() method. In the Main() method, we created two variables choice1 and choice2 that are initialized with 2 and 2.2 respectively.

In the above program, we defined "select case" inside the "select case", which is known as a nested select case. Here, "case 2.2" will be executed and then print the appropriate message on the console screen.

VB.Net Basic Programs »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.