Mixing VB and C#?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've heard it's possible to write multi-language programs, but can't find any examples of this. I'd like to write a program where the gui is in VB but the non-form classes are written in C#. Is there an example or tutorial on how to write an application which mix VB and C#?

Thanks
[Tim]
 
Create a new solution project in either langauge - for the sake of
illustration, use VB.NEt. Now, Go to file - Add and select New Project.
Make sure you use Add and not Open. Then select C# and the Class Library or
whichever template you want. Then, go back to the VB Project (they are both
in the same solution) and select Add Reference. on the third tab of Add
Reference (after .NET and COM) you can select the C# project. That's pretty
much all there is to it. If you add the project then VS.NEt will establish
a default build order for you.

Let me know if you have any questions.

Bill

--
W.G. Ryan MVP Windows - Embedded

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
Tim said:
I've heard it's possible to write multi-language programs, but can't find
any examples of this. I'd like to write a program where the gui is in VB
but the non-form classes are written in C#. Is there an example or tutorial
on how to write an application which mix VB and C#?
Thanks
[Tim]
 
Hi Tim,

William described one way that is supported by VS.NET (IDE).
But there is more - .net allows you to mix languages even in same assembly
(which isn't supported by IDE).
To see a sample check framework sdk sample - if I remember there is at least
one.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Tim said:
I've heard it's possible to write multi-language programs, but can't find
any examples of this. I'd like to write a program where the gui is in VB
but the non-form classes are written in C#. Is there an example or tutorial
on how to write an application which mix VB and C#?
Thanks
[Tim]
 
Thank you, this did work. What I wasn't doing was adding the reference to the VB project. I was hoping there was a way of doing this all within the IDE, otherwise the mixed language feature would lose much of it's luster.

[Tim]

William Ryan eMVP said:
Create a new solution project in either langauge - for the sake of
illustration, use VB.NEt. Now, Go to file - Add and select New Project.
Make sure you use Add and not Open. Then select C# and the Class Library or
whichever template you want. Then, go back to the VB Project (they are both
in the same solution) and select Add Reference. on the third tab of Add
Reference (after .NET and COM) you can select the C# project. That's pretty
much all there is to it. If you add the project then VS.NEt will establish
a default build order for you.

Let me know if you have any questions.

Bill

--
W.G. Ryan MVP Windows - Embedded

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
Tim said:
I've heard it's possible to write multi-language programs, but can't find
any examples of this. I'd like to write a program where the gui is in VB
but the non-form classes are written in C#. Is there an example or tutorial
on how to write an application which mix VB and C#?
Thanks
[Tim]
 
Back
Top