Is there a way to convert VB forms to VC?

  • Thread starter Thread starter Marc Reinig
  • Start date Start date
i threw away c++....good new for vb.net :-P

Lucas said:
@TK2MSFTNGP09.phx.gbl:




Older version? What are you talking about?

C# is a managed language like VB.NET. It has all the features of VB.NET and
a couple of extras (VB.NET will probably get those extra features next
version around).

C++ on the other hand is an unmanaged language (but there is a C++ Managed
version too) which you to write native code from VS.NET.

VB.NET, C#.NET, etc all the .NET languages compile to an intermediatary
language for the .NET runtime... so theoretically writing for C++ should be
faster and often is.

The drawback? C++ is more difficult to write for and you need to becareful
in regards to garbage collection, memory access, etc, because all of these
features are no handled by C++ and you must do it yourself.
 
I'm still unclear. If I have C or C++ code that doesn't make any calls to
managed resources, they only provide algorithm execution and access to
capture devices through 3rd party DLL's::
1. Can I integrate these modules with VB.NET directly and compile a single
executable?
2. Do I have to do something to the code to make it integrate with VB.NET
(besides translating to VB)
3. Must I make these modules into DLL's?

Thanks in advance,

Marco
________________________
Marc Reinig
UCO/Lick Observatory
Laboratory for Adaptive Optics
 
I have C and C++ modules that simply implement algorithms and talk to
external 3rd party hardware through DLL's and their drivers. What is
involved in using them with VB.NET, short of making them DLL's. How can I
make them managaged code. They are not accessing any classes, they either
take an array of data, process it and return it or are told to retrieve
images, get them, process them and return them.

Thanks in advance,

Marco
________________________
Marc Reinig
UCO/Lick Observatory
Laboratory for Adaptive Optics
 
We can use the VB.NET code in VC++.NET(managed code).
In fact, after the .NET code has been compiled(whatever VB,NET C#.NET and
so on), they will be compiled into MSIL code which is kind of Assembly
language based on .NET framework, in this level whether it is written with
VB,NET C# or else is not important as long as they are managed code.

So, lets say I have two projects, one a VB.NET project and another a
VC++.NET project. How would I combine them into a single project so I don't
have to rewrite them? i.e. if I wanted to use a set of forms or modules I
had done in VB in the C++ or vice versa.
But unmanaged code(e.g. pure C++) can not access to the managed code
directly, we need expose the mananged code as a COM Server, so that the
unmanaged code can access it as COM. But we still need .NET framework
support to run the manged code as a COM server.

If I had a set of routines written in C ort C++ (not .NET) that execute an
algorithm on an array of data and make no calls to any of the classes in
..NET (assume they take a two dimensional array of INTEGERS and perform some
mathematical process of them, can my VB.NET project incorporate these
routines? What would I have to do to them to incorporate them?

Thanks in advance,

Marco
________________________
Marc Reinig
UCO/Lick Observatory
Laboratory for Adaptive Optics
 
I'm still unclear. If I have C or C++ code that doesn't make any
calls to managed resources, they only provide algorithm execution and
access to capture devices through 3rd party DLL's::
1. Can I integrate these modules with VB.NET directly and compile a
single executable?

No, as far as I am aware, you cannot mix and match different languages
within the same project. HOWEVER, mixing of language is a feature of
VS.NET 2005.

What you can do is create a managed C++ project, build a DLL, and then
reference the DLL from your VB.NET project.

OR, you can stick with unmanaged C/C++ code, build a Windows API DLL,
declare the functions in VB.NET, and use the functions via the DLL.

OR lastly, you can convert your C/C++ code into a COM object and
reference it in VB.NET via interops (Interops are automatically
generated by VS.NET).
2. Do I have to do something to the code to make it integrate with
VB.NET (besides translating to VB)

Make a note that VB.NET doesn't really support pointers and direct
memory access. So if you're doing alot of unmanaged operations, the
logic may need to be rewritten.
3. Must I make these modules into DLL's?

No, you can always create a new class and compile it into your .exe (and
not expose the files as a library).
 
* Marc Reinig:
I'm still unclear. If I have C or C++ code that doesn't make any calls to
managed resources, they only provide algorithm execution and access to
capture devices through 3rd party DLL's::

1. Can I integrate these modules with VB.NET directly and compile a single
executable?
No.


2. Do I have to do something to the code to make it integrate with VB.NET
(besides translating to VB)

Presumably you mean, "other than the option of translating the code to
VB".

It depends.

Assuming you want to call C++ code from VB.NET (this includes the case
of calling C code), you can:

A Package the C++ code as an ordinary unmanaged DLL, then use platform
invoke to access the DLL functions from VB.NET.

B Package the C++ code as a COM class, e.g. a DLL, and use the .NET
tool to automatically create a .NET wrapper class for a COM class,
which you can then use from VB.NET as any other .NET class (if it's
already available as a COM/ActiveX class this would be natural).

C Package the C++ code as a .NET class or classes, physically in a
DLL (which means you do all the managed <-> unmanaged glue code in
C++), which you can then use from VB.NET as any other .NET class.

Option C is possibly the cleanest approach, because at the VB level you
then only have .NET data types.

But there are many other approaches than directly calling the code from
VB. For example, you could make a C++ process that communicated with
the VB.NET GUI via mailslots or files or whatever. It's difficult to
say without knowing more about the concrete problem.

3. Must I make these modules into DLL's?

No, but you _can_ do that, and it's probably the most practical way to
go.
 
Hi

I am sorry what I mean is from access managed code from unmanaged code, the
COM Interop will be a better solution.
If you want to access unmanaged code(C++) from managed code(VB.NET), we can
use the P/Invoke(i.e. what you have said declare function...).
I am sorry for my confustion.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi
So, lets say I have two projects, one a VB.NET project and another a
VC++.NET project. How would I combine them into a single project so I don't
have to rewrite them? i.e. if I wanted to use a set of forms or modules I
had done in VB in the C++ or vice versa.

I assume what what you mean here is all in the managed category. We can not
use both .vb source code file and .cpp source code file in one project,
because they will be compiled by two different compiler(vbc.exe and
cl.exe). For your scenario, we have to use two project, or you can build
the one of the project into an assembly, and add reference to that assembly
in another project.

If I had a set of routines written in C ort C++ (not .NET) that execute an
algorithm on an array of data and make no calls to any of the classes in
.NET (assume they take a two dimensional array of INTEGERS and perform some
mathematical process of them, can my VB.NET project incorporate these
routines? What would I have to do to them to incorporate them?

Based on my understanding, you wants to call unmanaged code(pure C++) from
VB.NET(managed code).
For this scenario, we can expose the C++ function as DLL export function so
that we can use VB.NET to call them via P/Invoke just as we call win32 API
in VB.NET.
Also you may try to write the C++ dll as a COM server, so that in VB.NET we
can directly add reference to the COM dll and call its method.

For detailed information you may try to take a look at the link below.
Interoperating with Unmanaged Code
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconinteroperatingwithunmanagedcode.asp

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top