0% found this document useful (0 votes)
22 views

Switch Case

This code uses a switch case statement to perform basic math operations based on user input. The user is prompted to select an operation and enter two numbers. A select case statement then evaluates the operation choice and performs the corresponding math, displaying the result in a message box. Invalid choices will display an error message.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Switch Case

This code uses a switch case statement to perform basic math operations based on user input. The user is prompted to select an operation and enter two numbers. A select case statement then evaluates the operation choice and performs the corresponding math, displaying the result in a message box. Invalid choices will display an error message.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 8

Switch case

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click

Dim a, b, c, ch As Integer

ch = InputBox("1.Add 2.Sub 3.Mul 4.Div Enter your choice.")

a = InputBox("enter 1st no")

b = InputBox("enter 2nd no")

Select Case ch

Case 1

c = a + b

MsgBox("Addition of 2 Numbers=" & c)

Case 2

c = a - b

MsgBox("Substraction of 2 Numbers =" & c)

Case 3

c = a * b

MsgBox("Multiplication of 2 Numbers =" & c)

Case 4

c = a / b

MsgBox("Division of 2 Numbers =" & c)

Case Else

MsgBox("invalid choice.")

End Select
End Sub

End Class

You might also like