[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Passing Data from C# to VB6 Active X control (and vice versa)

Posted on 2008-11-17
Medium Priority
Last Modified: 2013-12-26
I have an active X control written in VB6.  I am creating a C# project and need to pass data back and forth to the active x control.    Cant I just add the VB6 control to C# project reference and then be able to see public methods and send data over?   Is this possible?  What packages are needed to do this? COM.Interop?

Please help as soon as possible.


Question by:JohnnyKnoxville
LVL 12

Accepted Solution

ShazbotOK earned 700 total points
ID: 22984617
So your wanting a C# app to consume the VB6 ActiveX?  Yes com interop would be needed, is this a UI control? you will need to add it as a resource in that case.

Author Comment

ID: 22987042
The Active X control  must be registered with a 3rd party app.  This creates somewhat of a built in panel in the 3rd party app.  When the 3rd party app loads, it loads my active X control.  Now...if I have a .NET project and need to grab the handle of this active x control....how is this accomplished?

If I simply use..

MyActiveXControl myCtrl = new MyActiveXControl();

This will give me a new instance.  What I need is the existing handle to the instance when it loaded in the 3rd party app.  I need to be able to populate data into the VB6 controls (text box , combobox, etc)

I tried to create a handle to the user control using CopyMemory  and expose it in a public class.  

Now I try this in C#...

MyActiveXControl.clsEventManagement myCtrl = new MyActiveXControl.clsEventManagement();
myCtrl.PassDataToTextBox("Some String");

This throws an error:

Retrieving the COM class Factory for component with CLSID -{21301F0D-E249-4906-9D85-87D9DE8559EF  Failed due to the following reason 80040154

Im completely stuck.  Im beginning to think its not possible to pass data back and forth because I cant get the original handle.  Is there a way to get a list of active window handles and look for my active x control?  Then try to grab it that way?

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month19 days, 20 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question