Did you know that, if you use the App_Code folder in your C# application, you can also use VB class files in your project?
There are 2 things you need to do first.
You just need to create a separate folder (let’s call it VBFiles) within the App_Code where your VB files will reside. This will assure that they are compiled separately.
Then, you need to create a small section in the web.config file, inside the compilation section:
<codeSubDirectories> <add directoryName="VBFiles" /> </codeSubDirectories>
Also, note, that, even if your project is a C# project, you can even create a new VB class file from within the application (just by choosing the VB.Net template when creating the class file)
To use the newly added VB.Net class file, you’d access it in code just like any other class. Here, the scenario is that there is a class called ‘VBCode’ which has a function called ‘WriteWelcome’ returning a string – “All Things DotNet rocks!!”:
Public Class VBCode Public Function WriteWelcome() As String Return "All Things DotNet rocks!!" End Function End Class
Inside the C# code behind file, you’d put something like this:
VBCode vb=new VBCode() ; txtName.Text = vb.WriteWelcome();
That’s all there is to consume a VB.Net class file inside a C# application.
All Things DotNet Discussed – Winforms/ASP.Net/SharePoint/WPF