VB Switch Case Examples

Switch Case Example

Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text

Namespace Program6
    Class Program
        Private Shared Sub Main(ByVal args As String())
            Dim a, b, c As Integer
            Console.WriteLine("Enter a,b values")
            a = Integer.Parse(Console.ReadLine())
            b = Integer.Parse(Console.ReadLine())
A:
            Console.Clear()
            Console.WriteLine("1.Addition.")
            Console.WriteLine("2.Subtraction.")
            Console.WriteLine("3.Multiplication.")
            Console.WriteLine("4.Division.")
            Console.WriteLine("Enter your choice ")
            c = Integer.Parse(Console.ReadLine())

            Select Case c
                Case 1
                    Console.WriteLine("A+B={0}", (a + b))
                    Console.ReadKey()
                    GoTo A
                Case 2
                    Console.WriteLine("A-B={0}", (a - b))
                    Console.ReadKey()
                    GoTo A
                Case 3
                    Console.WriteLine("AXB={0}", (a * b))
                    Console.ReadKey()
                    GoTo A
                Case 4
                    Console.WriteLine("A/B={0}", (a / b))
                    Console.ReadKey()
                    GoTo A
                Case Else
                    Console.WriteLine("Your choice is out of Range")
                    Exit Select
            End Select
        End Sub
    End Class
End Namespace



©Copyright 2016 All Rights Reserved LearnDotNetHome.com