0% found this document useful (0 votes)
1K views

Practical No. 3: Implement A Message Box Program & Arithmetic Expression

The document describes two programs that perform arithmetic operations using message boxes. The first program uses hardcoded integer values to perform subtraction, multiplication, addition, and division, displaying the results in message boxes. The second program uses InputBox to accept user input for the integer values, then performs the same arithmetic operations and displays the results in message boxes. Both programs illustrate using message boxes to output the results of arithmetic expressions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views

Practical No. 3: Implement A Message Box Program & Arithmetic Expression

The document describes two programs that perform arithmetic operations using message boxes. The first program uses hardcoded integer values to perform subtraction, multiplication, addition, and division, displaying the results in message boxes. The second program uses InputBox to accept user input for the integer values, then performs the same arithmetic operations and displays the results in message boxes. Both programs illustrate using message boxes to output the results of arithmetic expressions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Practical No.

3 : Implement a Message Box


program & Arithmetic Expression.

1. Implement the program to generate result


of any arithmetic operation using MsgBox()..
Code :
Public Class Form1

Dim no1 As Integer


Dim no2 As Integer

Private Sub Button2_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button2.Click
Dim Substraction As Integer
no1 = 16
no2 = 5
Substraction = no1 - no2
MessageBox.Show("Subtraction of the integers " & no1
& " - " & no2 & " = " & Substraction)
End Sub

Private Sub Button3_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button3.Click
Dim Multiplication As Integer
no1 = 5
no2 = 9
Multiplication = no1 * no2
MessageBox.Show("Multiplication of the integers " &
no1 & " * " & no2 & " = " & Multiplication)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button1.Click
Dim Addition As Integer
no1 = 4
no2 = 5
Addition = no1 + no2
MessageBox.Show("Sum of the integers " & no1 & " + "
& no2 & " = " & Addition)
End Sub

Private Sub Button4_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button4.Click
Dim Div As Integer
no1 = 18
no2 = 2
Div = no1 / no2
MessageBox.Show("Sum of the integers " & no1 & " / "
& no2 & " = " & Div)
End Sub

End Class

Output :
2. Write a program using InputBox(), MsgBox()
& perform various arithmetic expression.
Code :
Public Class Form1
Dim a As Integer
Dim b As Integer
Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim Sum As Integer
a = InputBox("Enter the value of a :")
b = InputBox("Enter the value of b : ")

Sum = a + b

MessageBox.Show("Sum of two integers is : " & Sum)

End Sub

Private Sub Button2_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button2.Click
Dim Subtraction As Integer
a = InputBox("Enter the value of a :")
b = InputBox("Enter the value of b : ")

Subtraction = a - b

MessageBox.Show("Subtraction of two integers is : "


& Subtraction)
End Sub

Private Sub Button3_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button3.Click
Dim Multiply As Integer
a = InputBox("Enter the value of a :")
b = InputBox("Enter the value of b : ")

Multiply = a * b

MessageBox.Show("Multiplication of two integers is :


" & Multiply)
End Sub

Private Sub Button4_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button4.Click
Dim Div As Integer
a = InputBox("Enter the value of a :")
b = InputBox("Enter the value of b : ")

Div = a / b

MessageBox.Show("Division of two integers is : " &


Div)
End Sub
End Class

Output :

You might also like