Visual C++ Program for the Implementation of ActiveX Template Library(ATL) | CS1255 - Visual Programming Laboratory

AIM:
To write a Visual C++ Program for the Implementation of ActiveX Template Library(ATL) in CS1255 - Visual Programming Lab.

SOURCE CODE:
Visual Basic:
Dim w As Long
Dim x As Long
Dim y As Long
Dim z As Long
Dim math As String

Private Sub Command1_Click()
Dim c As Long
c = Val(Text1.Text)
Text1.Text = c * 10 + 7
End Sub

Private Sub Command10_Click()
Dim c As Long
Text1.Text = " "
End Sub

Private Sub Command11_Click()
Dim c As Long
c = Val(Text1.Text)
Text1.Text = c * 10 + 0
End Sub

Private Sub Command12_Click()
If Text1.Text = " " Then Exit Sub
y = Val(Text1.Text)
Select Case math
Case "+"
Dim r As New CALCULATORLib.sample
Set r = New sample
r.Add x, y, z
Text1.Text = z
Case "-"
Set r = New sample
r.Sub x, y, z
Text1.Text = z
Case "*"
Set r = New sample
r.prod x, y, z
Text1.Text = z
Case "/"
Set r = New sample
r.div x, y, z
Text1.Text = z
End Select
End Sub

Private Sub Command13_Click()
w = 0
Dim r As New CALCULATORLib.sample
Set r = New sample
r.Add Text1.Text, w, x
Text1.Text = 0
math = "+"
End Sub

Private Sub Command14_Click()
w = 0
Dim r As New CALCULATORLib.sample
Set r = New sample
r.Sub Text1.Text, w, x
Text1.Text = 0
math = "-"
End Sub

Private Sub Command15_Click()
w = 1
Dim r As New CALCULATORLib.sample
Set r = New sample
r.prod Text1.Text, w, x
Text1.Text = 0
math = "*"
End Sub

Private Sub Command16_Click()
w = 1
Dim r As New CALCULATORLib.sample
Set r = New sample
r.div Text1.Text, w, x
Text1.Text = 0
math = "/"
End Sub

Private Sub Command2_Click()
Dim c As Long
c = Val(Text1.Text)
Text1.Text = c * 10 + 8
End Sub

Private Sub Command3_Click()
Dim c As Long
c = Val(Text1.Text)
Text1.Text = c * 10 + 9
End Sub

Private Sub Command4_Click()
Dim c As Long
c = Val(Text1.Text)
Text1.Text = c * 10 + 4
End Sub

Private Sub Command5_Click()
Dim c As Long
c = Val(Text1.Text)
Text1.Text = c * 10 + 5
End Sub

Private Sub Command6_Click()
Dim c As Long
c = Val(Text1.Text)
Text1.Text = c * 10 + 6
End Sub

Private Sub Command7_Click()
Dim c As Long
c = Val(Text1.Text)
Text1.Text = c * 10 + 1
End Sub

Private Sub Command8_Click()
Dim c As Long
c = Val(Text1.Text)
Text1.Text = c * 10 + 2
End Sub

Private Sub Command9_Click()
Dim c As Long
c = Val(Text1.Text)
Text1.Text = c * 10 + 3
End Sub

Visual C++:
// calculation.cpp : Implementation of Ccalculation
#include "stdafx.h"
#include "Calculator.h"
#include "calculation.h"
/////////////////////////////////////////////////////////////////////////////
// Ccalculation

STDMETHODIMP Ccalculation::add(int a, int b, long *c)
{
    *c=a+b;
    return S_OK;
}
STDMETHODIMP Ccalculation::sub(int a, int b, long *c)
{
    *c=a-b;
    return S_OK;
}
STDMETHODIMP Ccalculation::product(int a, int b, long *c)
{
    *c=a*b;
    return S_OK;
}
STDMETHODIMP Ccalculation::division(int a, int b, long *c)
{
    *c=a/b;
    return S_OK;
}

OUTPUT:

Previous
Next Post »

If you still didn't find what you're looking for, you can search this website below: