0% found this document useful (0 votes)
30 views3 pages

Coding

This code defines two classes - Class1 and Class2 - for performing basic mathematical operations. Class1 defines properties to store operand values. Class2 inherits from Class1 and defines methods to add, subtract, multiply, divide, and get the modulus of two operands. A form class connects text boxes to call the math methods and display results.

Uploaded by

Amutha Arun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views3 pages

Coding

This code defines two classes - Class1 and Class2 - for performing basic mathematical operations. Class1 defines properties to store operand values. Class2 inherits from Class1 and defines methods to add, subtract, multiply, divide, and get the modulus of two operands. A form class connects text boxes to call the math methods and display results.

Uploaded by

Amutha Arun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Coding:

~~~~~~
Public Class Class1
Private op1, op2
Property operand1 () As Single
Get
Return op1
End Get
Set (ByVal value As Single)
op1 = value
End Set
End Property
Property operand2 () As Single
Get
Return op2
End Get
Set (ByVal value As Single)
op2 = value
End Set
End Property
End Class
Public Class Class2
Inherits Class1
Public Function add (ByVal op1 As Single, ByVal op2 As Single) As Single
Return op1 + op2
End Function
Public Function subtract (ByVal op1 As Single, ByVal op2 As Single) As Single
Return op1 - op2
End Function
Public Function multiply (ByVal op1 As Single, ByVal op2 As Single) As Single
Return op1 * op2
End Function
Public Function divide (ByVal op1 As Single, ByVal op2 As Single) As Single

Return op1 / op2


End Function
Public Function modulus (ByVal op1 As Integer, ByVal op2 As Integer) As Integer
Return op1 Mod op2
End Function
End Class

Public Class Form1


Dim cls As New Class2
Private Sub addcmd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Handles addcmd.Click
cls.operand1 = Single.Parse(TextBox1.Text)
cls.operand2 = Single.Parse(TextBox2.Text)
TextBox3.Text = Single.Parse(cls.add(cls.operand1, cls.operand2))
End Sub
Private Sub Subcmd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Handles Subcmd.Click
cls.operand1 = Single.Parse(TextBox1.Text)
cls.operand2 = Single.Parse(TextBox2.Text)
TextBox3.Text = Single.Parse(cls.subtract(cls.operand1, cls.operand2))
End Sub
Private Sub divcmd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Handles divcmd.Click
cls.operand1 = Single.Parse(TextBox1.Text)
cls.operand2 = Single.Parse(TextBox2.Text)
TextBox3.Text = Single.Parse(cls.divide(cls.operand1, cls.operand2))
End Sub

Private Sub mulcmd_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
Handles mulcmd.Click
cls.operand1 = Single.Parse(TextBox1.Text)
cls.operand2 = Single.Parse(TextBox2.Text)
TextBox3.Text = Single.Parse(cls.multiply(cls.operand1, cls.operand2))
End Sub
Private Sub modcmd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Handles modcmd.Click
cls.operand1 = Single.Parse(TextBox1.Text)
cls.operand2 = Single.Parse(TextBox2.Text)
TextBox3.Text = Single.Parse(cls.modulus(cls.operand1, cls.operand2))
End Sub
End Class

You might also like