Solved

Combining VB.net and C++ .net

Posted on 2004-08-27
2
217 Views
Last Modified: 2012-06-21
Can an application be built using C++ .Net and VB .Net code?  If so can someone point me to or give me an elementary example that shows this?  

Thanks.
0
Comment
Question by:hess586
2 Comments
 
LVL 2

Accepted Solution

by:
lgawlik earned 50 total points
ID: 11919529
Yes.  That is a key concept behind the .NET Framework.
You can have class libraries built in managed C++.NET and then have UI programmers write VB.NET GUIs to use your C++ (managed) code.

You can accomplish a test yourself by doing this.

1) Create a new solution
2) Add a new C++ Managed Class Library Project to the solution
  Within that Class Library add a class named Hello, like

// This is the main DLL file.
#include "stdafx.h"
#include "cppClassLibrary.h"

namespace cppClassLibrary
{
   __gc public class Hello {
   public:
      Hello() {
      }

      String* HelloWorld()
      {
         String* world = L"Hello World";
         return world;
      }
   };
}

3) Next add a VB Windows Forms Project named vbHelloWorldGUI
4) On the form add a label, leave the default name to Label1
5) Add a project referenece from your VB App to your Managed C++ project
6) Add this code to Form1.FormLoad, populates Label1 with the results of the Hello.HelloWorld property.

   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      Dim cppCL As New cppClassLibrary.Hello()
      Label1.Text = cppCL.HelloWorld
   End Sub

7) Execute

You should end up with a Managed C++ Class Library being called from a VB Windows Form application.
0
 
LVL 2

Expert Comment

by:dimitry_dimitry
ID: 11929143
Why not?
Add MC++ project to references, or as pre-compiled assembly, in case the project is not in your hands;)
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now