Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


call procedure in vb.net form class from c# class?

Posted on 2004-10-25
Medium Priority
Last Modified: 2010-04-15
hi all,

I don't code in c# and know little about it, but I have a library of code that I'm using.   Primarily I code in vb.net.   I have added error handling within many of the functions and procedures of the c# library classes.   I would like to call a procedure that is in my vb.net form from within my c# code.   Can someone please show me how I can do this?   The procedure is just a one liner name, no parameters to pass or anything.   also, the vb.net form is already open.

Question by:OnlineNoob
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 19

Expert Comment

by:Fahad Mukhtar
ID: 12407342
if you meant to say that you have a class library written in C# then you can easily use that DLL in your VB.NET Code. Just click *Project-> Add Reference* menu and browse for the C# DLL.  Then you can easily use the classes in that DLL by using either

myCSharpClass c  = new myCSharpClass();

or without *using* keyword

MYCSHARPDLL.myCSharpClass c  = new MYCSHARPDLL.myCSharpClass();


Author Comment

ID: 12407730
I have sevearl C# classes uncompiled in my solution, along with my vb.net project.   I would like to call public procedure in the vb.net form class from within my c# class.

Expert Comment

ID: 12407828
Check this url http://www.codeproject.com/csharp/GBVB.asp
It helps to convert vb.net code to c#.

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 19

Expert Comment

by:Fahad Mukhtar
ID: 12407872
you can put your C# code in a dll and then acces in vb.net application easily...
I dont think you can use both C# classes in vb.net it in the same application
LVL 19

Expert Comment

by:Fahad Mukhtar
ID: 12407923
It would be possible in the upcoming version of VS.Net

Accepted Solution

etmendz earned 1000 total points
ID: 12408755
So the VB.Net project is a Windows application. Is the C# project also a Widnows application? Or is the C# project .dll?

Anyways, please remember that an .EXE application has an application domain which makes its bounderies clear: its members are for itself. That means, it is impossible to let a C# project access the members of a VB.Net application project. But you can let the VB.Net application project access the members of the C# project.

What you can do is to create a VB.Net .dll that defines the member you wanted to share to other projects. You can then use this .dll in both your VB.Net app and your C# .dll.

Have fun.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

610 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