Please help in making an ActiveX control of a class (no GUI needed)

Hi All,

      I wanted to make a ActiveX control (no GUI support) which has all the methods defined in the class shown below including the operator== overloading and copy contructor.  Later on I have to use these methods in a VBA.

I got 3-4 replies but either the hint provided didn't worked out or I got syntax errors after compiling in MS VS C++ 6.
I have allready spent 3 days on this problem but could not able to solve it. Please help me in solving it.

Please reply as quick as possible in details. I will be very thankful,  if you could build the ActiveX control by taking my Test.cpp as an input and send the tar file of the complete project at the following address:
Thanks in advance,

With Regards,

//Test class
#include <iostream>
#include <string>
using namespace std;

class Test
    unsigned int total;
    Test(const Test& testObj);
    void addValue(unsigned int value);
    unsigned int getValue();
    bool operator== (const Test& testObj);

     total = 0;


Test::Test(const Test& testObj)
    this->total =;

void Test::addValue(unsigned int value)
    total = total + value;

unsigned int Test::getValue()
    return total;

bool Test::operator==(const Test& testObj)
    if (this->total ==
        return true;
        return false;
Who is Participating?
Computer101Connect With a Mentor Commented:
PAQed - no points refunded (of 125)

E-E Admin
Hi Pawan,
Please try to make an ActiveX control with the inputs that I gave you. You will learn when you do it else you will never learn.
It is very simple to write a control for this class. Create an MFC ActiveX control project and add the required methods and properties as I suggested..
The class members which you intend to send or receive to VBA or any other application can be made as properties. And you can achieve this easily by using the set property and get property.
Also the methods like AddValue can be added to the ActiveX interface methods.
Plz let me know if you have any difficulties in making the activex control.
Good luck,
Plz post the errors that you are getting. So that we can help you.


COM [ActiveX] is supposed to be language independant. As such the ability to expose C++ esque methods is not available.

How many languages have operator== ? Specifically, does VBA ?!

As nonubik suggested ( using isEqual( ) and clone( ) is a common implementaton for scenarios such as these.

Also, as lakshman_ce suggested, specific error codes/messages would aid your cause greatly.
Nobody has mentioned this yet, but if you want to use your object from VBA, you're going to have to implement an automation aware component. i.e. one that implements a dispinterface (IDispatch in COM parlance).
All Courses

From novice to tech pro — start learning today.