Sometimes in the real scenario you need to access a function of a VB class in a C# page, so there is nothing different in this scenario. You just need to create the object of the VB class in your C# page and just use it. I will explain it in detail in the following procedure.
Step 1: Create a ASP.NET empty website named "TestApp" using C#.

Step 2: Create a Web From using C# in the website named "Default.aspx".

Step 3: Create a class file in the website named "MyClass1.vb" using Visual Basic.

Step 4: Write a function of addition in the VB class that accepts 2 integer values and return the addition of both of the values using another integer variable.
Public Function Add(value1 As Integer, value2 As Integer) As Integer
Dim result = (value1 + value2)
Return result
End Function

Step 5: Call the addition function of the VB class in the C# page by creating the object of MyClass1.
Print the addition value on the page.
MyClass1 obj = new MyClass1();int addition = obj.Add(2, 3);
Response.Write(addition.ToString());

Run the page to see the output.


chandan jiPosted Dec 26, 2016, 6:52 AM
Sorry How to call Visual Basic Subroutine in C# project
chandan jiPosted Dec 26, 2016, 6:38 AM
How to call a vba subroutine in C# project
Rahul BansalPosted Dec 25, 2014, 11:06 PM
It's a difference of Version of Visual Studio and i am using Ultimate version of Visual studio 2012 that's why i get. Might be you are using the other version or web express.
nilesh dubeyPosted Dec 24, 2014, 10:31 AM
I am trying to implement the above example but i am unable to get 3rd step, language option, how will i get the 3rd option.