[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Importing C++ classes in Visual Basic

Posted on 1997-05-20
5
Medium Priority
?
266 Views
Last Modified: 2013-11-25
Is it possible to import a class exported from a Visual C++ DLL into Visual Basic (either 4.0 or 5.0)?  If so how is this done?
0
Comment
Question by:berven
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Author Comment

by:berven
ID: 1426423
Edited text of question
0
 
LVL 3

Accepted Solution

by:
rmichels earned 200 total points
ID: 1426424
It is not possible to import a C++ class into VB and use it as a class. I offer up two suggestions on how to use C++ classes in VB.  

1) Implement the C++ class as an activeX object.

2) Write straight 'C' wrappers around the C++ classes.  Have the C funtions return a pointer (just a long) to the C++ classes managed by the C routines.  That was your VB can at least have a handle to a class, allowing multiple instances of classes to be created, but only the C funtion know how to interpret the handle.
0
 

Author Comment

by:berven
ID: 1426425
Thank you.  I was hoping I cound get away without having to wrap the class or implement it as an activeX object.
 
I read an article by Bruce McKinney called Extending Visual Basic with C++ DLL's (Microsoft Press April 1996) which led me to hope that this feature may be available in VB5.

Do you know if any other compilers (Borland Delphi or Borland Builder) can import C++ classes?
0
 
LVL 3

Expert Comment

by:rmichels
ID: 1426426
No feature has been added to VB5 that I know of regarding directly using classes from a C++ dll.  There are name mangling issues, stack frame issues (the this pointer).  I have never used Delphi, so I can't speak to that tool.

Creating an ActiveX control with Microsoft Visual C 5.0 is not that difficult.  Microsoft provides wizards that create a class that has all of the required guts for an activex control and you add your own functionality as needed.
0
 

Author Comment

by:berven
ID: 1426427
I will give the ActiveX control a try.  Thanks again.
0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

649 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