Home »
VB.Net »
VB.Net Programs
VB.Net program to demonstrate the duplicate case in the 'select case'
By Nidhi Last Updated : November 11, 2024
Duplicate case in the 'select case' in VB.Net
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 code to demonstrate the examples of duplicate case in the 'select case'
'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 »