473,386 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

using VB.NET classes in C#

hi,

can anyone tell me how could I use the VB.NET classes
within my C#?

I tried doing the same, but in vain. I have a VB.NET class
in a VB.NET project. It has the same name for the
namespace as for the C# class. It compiled. But my C#
project does not recognize it when I try calling it.
Moreover, I'm unable to see the VB.NET class within C#.

Kindly correct me with the correct procedure of doing
this..

thanks,
irfan
Nov 15 '05 #1
3 10111
Hi,

1. Reference the assembly containing the VB .NET class from the C# project
2. Add a "using" statement that would import that VB .NET class' namespace
(if it differs from the one used in the C# class importing the VB .NET one)
to the file containing the C# class.
3. The VB .NET class should become pretty visible in the C# project.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"irfan" <sy********@ge.com> wrote in message
news:01****************************@phx.gbl...
hi,

can anyone tell me how could I use the VB.NET classes
within my C#?

I tried doing the same, but in vain. I have a VB.NET class
in a VB.NET project. It has the same name for the
namespace as for the C# class. It compiled. But my C#
project does not recognize it when I try calling it.
Moreover, I'm unable to see the VB.NET class within C#.

Kindly correct me with the correct procedure of doing
this..

thanks,
irfan


Nov 15 '05 #2
Hi Dmitriy Lapshin,

first of all, thanx a ton for ur reply..

here's the code I use

VB.NET

Namespace MyNamespace
Public Class CVB
Public Sub CVB()

End Sub

Function vbFun(ByVal name As String) As String
vbFun = name.ToUpper()
End Function

End Class
End Namespace

C#
using System;

namespace MyNamespace
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class CClass
{
public CClass()
{
//
// TODO: Add constructor logic here
//
}
public string myMethod()
{
CVB cc = new CVB();
return cc.vbFun("irfan");
}

}
}

I am unable to compile and generate an assembly for the vb
class.

Inorder to use vb class in C#, I should create an assembly?

TIA
irfan
Nov 15 '05 #3
"irfan" wrote:
Hi Dmitriy Lapshin,

first of all, thanx a ton for ur reply..

here's the code I use

VB.NET

Namespace MyNamespace
Public Class CVB
Public Sub CVB()

End Sub

Function vbFun(ByVal name As String) As String
vbFun = name.ToUpper()
End Function

End Class
End Namespace

C#
using System;

namespace MyNamespace
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class CClass
{
public CClass()
{
//
// TODO: Add constructor logic here
//
}
public string myMethod()
{
CVB cc = new CVB();
return cc.vbFun("irfan");
}

}
}

I am unable to compile and generate an assembly for the vb
class.

Inorder to use vb class in C#, I should create an assembly?

TIA
irfan


By default, VB adds a namespace around the assemblies content that is
usually the name of the VB Assembly. You can find that under project
properties->common properties->general->root namespace
so you either can remove this or use your VB class like this:
YourVbAssembly.MyNamespace.CVB c = new YourVbAssembly.MyNamespace.CVB()

HTH,
Andy
--
To mail me directly, remove the NO*SPAM parts in
NO***********@gmx.netNO*SPAM
Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: bissatch | last post by:
Hi, Generally if I re-use code, I use a function. If I need to use these functions over a number of pages I write the function to an include file where all pages have access. So when should I...
6
by: Jake D | last post by:
I understand how to load a DLL in C++ and use functions from it, however I have a DLL which I did not create which has some classes in it. I can't seem to find out how to use the classes to make...
1
by: Donald Welker | last post by:
I'm building a web forms project and would like to provide consistent connection, data adapter, dataset objects, etc. across multiple ASPX pages. I'm having problems with trying to make these...
0
by: Stu | last post by:
Hi, Ive been using classes as output from webservices which until now have worked well and have serialised into the xml i wanted. Now i want to have a structure of clients which have accounts...
0
by: The Confessor | last post by:
I have a rather sprawling application-in-progress in Visual Basic .NET 2003, and I'm using very specific naming conventions to avoid confusion and make the function of my code as self-evident as...
5
by: Richard Gromstein | last post by:
Hello, I have an exercise that I need to finish very soon and I really need help understanding what to do and how exactly to do it. I am working on reading the chapter right now and working on it...
3
by: apedosmil8 | last post by:
I am having problems with using classes. I'm not sure why this program will not run. I have pointed out the problem. Thanks #include <iostream> #include <iomanip> #include <cmath> using...
2
by: =?Utf-8?B?d2lubGlu?= | last post by:
Hello 1) I agree that useing classes is the best way to use VB.net. The question is how do you write a VB program without using classes? 2) For my own edification where can I see an actual...
3
by: Ramu528 | last post by:
Hi friends, I am populating a drop box from a table jos_qualifications. can anybody tell me how to populate a drop box using classes. something like $db->setQuery( $query ); this is my code...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.