ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

VB.Net program to demonstrate the duplicate case in the 'select case'

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

Here, we will define the duplicate case in the 'select case' without any error.

Program/Source Code:

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

'VB.Net program to demonstrate the duplicate 
'case in the "select case".

Module Module1

    Sub Main()
        Dim choice As Char

        Console.WriteLine("############################")
        Console.WriteLine("     a: India")
        Console.WriteLine("     a: Australia")
        Console.WriteLine("     c: USA")
        Console.WriteLine("     d: UK")
        Console.WriteLine("############################")
        Console.Write("Select your country: ")
        choice = Char.Parse(Console.ReadLine())

        Select Case choice
            Case "a"
                Console.WriteLine("India")
            Case "a"
                Console.WriteLine("Australia")
            Case "c"
                Console.WriteLine("USA")
            Case "d"
                Console.WriteLine("UK")
            Case Else
                Console.WriteLine("Invalid choice")
        End Select
    End Sub
    
End Module

Output:

############################
     a: India
     a: Australia
     c: USA
     d: UK
############################
Select your country: a
India
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 a variable choice of Char type.

In the above program, we defined the case a twice, which is duplicate but execute only one case which is defined before, but it does not produce any syntax error.

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.