Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Combining VB.net and C++ .net

Posted on 2004-08-27
2
Medium Priority
?
268 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 150 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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…
A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

618 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