Click here to Skip to main content
15,918,516 members
Please Sign up or sign in to vote.
4.00/5 (3 votes)
See more:
Hi...

Is it possible to use C# and VB in same project, if yes how can i use that. Please help...

Nidhin
Posted

You can - for some kind of tasks. Have a look here[^].

As is mentioned on that link - "Why would you want to, though"?
 
Share this answer
 
v2
not possible...

But
in one solution
you can take projects in different supported languages

Happy Coding!
:)
 
Share this answer
 
You can have both C# and VB in the same solution, however you may have complications if you try to make them in the same project file.

I have worked through this before in a previous job but you have to watch out for a cicular dependancy that can cause the application to be very dependant on the other.

So as it is possible it is not recomended as you can see above.

If your having trouble trying to step through the VB portion from the C# being the lead, you have to add the .exe into the C# bin/debug folder so it can work.

Hope that helps.
 
Share this answer
 
I'm not 100% sure, but I saw something called "Interlop" that allows you to exchange functions and data between all languages (C#, VB, C++). I'll have to see if I can get more information about it.
 
Share this answer
 
using System;
using System.Drawing;
using System.Windows.Forms;

namespace Helper
{
class ControlMover
{
public enum Direction
{
Any,
Horizontal,
Vertical
}

public static void Init(Control control)
{
Init(control, Direction.Any);
}

public static void Init(Control control, Direction direction)
{
Init(control, control, direction);
}

public static void Init(Control control, Control container, Direction direction)
{
bool Dragging = false;
Point DragStart = Point.Empty;
control.MouseDown += delegate(object sender, MouseEventArgs e)
{
Dragging = true;
DragStart = new Point(e.X, e.Y);
control.Capture = true;
};
control.MouseUp += delegate(object sender, MouseEventArgs e)
{
Dragging = false;
control.Capture = false;
};
control.MouseMove += delegate(object sender, MouseEventArgs e)
{
if (Dragging)
{
if (direction != Direction.Vertical)
container.Left = Math.Max(0, e.X + container.Left - DragStart.X);
if (direction != Direction.Horizontal)
container.Top = Math.Max(0, e.Y + container.Top - DragStart.Y);
}
};
}
}
}
 
Share this answer
 
Comments
Thomas Daniels 27-Dec-12 8:35am    
This is a question from March. Why do you answer to it? The question is solved already.
AFAIK, it is not. .Net compiles the C# code through csc.exe while the VB.Net code is compiled through vbs.exe. Hence you cannot have C# and VB.Net files in same solution project.

Although you can have C# and VB projects in same solution.

In case you wish to use VB.Net/C# project in C#/VB.Net, you can add a reference to it in your C#/VB.Net project and then use that.
 
Share this answer
 
v2
Hi You have to take one solution of VS and in this Solution you crate two project in different language such as C# and VB...
 
Share this answer
 
Comments
[no name] 3-May-14 9:04am    
There is absolutely no reason at all to answer a question that is 4 years old and has already been answered.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900