Solved

Combining VB.net and C++ .net

Posted on 2004-08-27
2
261 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
[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
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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

691 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