AIM:
To create a VB application for the implementation of simple calculator using ActiveX DLL.
ALGORITHM:
MiniCalc.dll
Step 1: Define the function addition() with the parameters n1, n2 as Integer
Step 2: Calculate addition n1+n2
Step 3: Define the function subtraction() with the parameters n1, n2 as Integer
Step 4: Calculate subtraction n1-n2
Step 5: Define the function multiplication() with the parameters n1, n2 as Integer
Step 6: Calculate multiplication n1*n2
Step 7: Define the function division() with the parameters n1, n2 as Double
Step 8: Calculate division n1/n2
Standard EXE
Step 1: Declare the object o for MINICALLib.MiniCalc
Step 2: Set the object o for MiniCalc
Step 3: Call the addition() function
Step 4: Set the object o for MiniCalc
Step 5: Call the subtraction() function
Step 6: Set the object o for MiniCalc
Step 7: Call the multiplication() function
Step 8: Set the object o for MiniCalc
Step 9: Call the division() function
SOURCE CODE:
MiniCalc.dll
Public Function addition(n1 As Integer, n2 As Integer) As Integeraddition = n1 + n2
End Function
Public Function subtraction(n1 As Integer, n2 As Integer) As Integer
subtraction = n1 - n2
End Function
Public Function multiplication(n1 As Integer, n2 As Integer) As Integer
multiplication = n1 * n2
End Function
Public Function division(n1 As Double, n2 As Double) As Double
division = n1 / n2
End Function
Standard EXE
Dim o As New MINICALLib.MiniCalc
Private Sub Command1_Click()
Set o = New MiniCalc
Text3.Text = o. addition(Val(Text1.Text), Val(Text2.Text))
End Sub
Private Sub Command2_Click()
Set o = New MiniCalc
Text3.Text = o. subtraction(Val(Text1.Text), Val(Text2.Text))
End Sub
Private Sub Command3_Click()
Set o = New MiniCalc
Text3.Text = o. multiplication(Val(Text1.Text), Val(Text2.Text))
End Sub
Private Sub Command4_Click()
Set o = New MiniCalc
Text3.Text = o. division(Val(Text1.Text), Val(Text2.Text))
End Sub
OUTPUT:
Thus the VB application for simple calculator using AciveX DLL was performed and the output was verified.
.
EmoticonEmoticon