VB.Net and C-Sharp

Posted on 2006-03-29
Last Modified: 2010-04-23

I have a problem in VB.Net that can only be solved in C# (problem with casting). I have made a C# class (from an example), is it possible to link this class into my VB application ? Or how can I use this class ?

Question by:ACAE
    LVL 34

    Expert Comment

    Complie the class and add a reference to it.

    Author Comment

    I can't seem to get it working. I added my class to my project (right-click on project --> Add --> Add existing item), selected the class (cs file), and build the project. But now i cannot add a line like

    DIM localclass AS NEW csharpclass

    this gives the error Type 'csharpclass' is not defined

    Perhaps I used the wrong definition for 'class', it is a source file not a project
    LVL 34

    Accepted Solution

    Create a new C# class library solution, build the solution.

    Now in your VB solution, in the solution Explorer, right click on "References" -> Select "Add Reference" browse to your file and add it (I'll assume your solution was called myClassLib and the class is called myClass)

    Now you can use

    Dim c as myClassLib.myClass 'etc......


    Author Comment


    Thx for your help, it works fine for me now.


    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Suggested Solutions

    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now