How to use VB.Net functions in C# project?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

How can I use a VB.Net function in a C# project. Is there a way to call it
directly from code? thx juvi
 
If you're inquiring about using the "built-in" Microsoft VB functions from
C# then you'll need to add a reference to the "Microsoft.VisualBasic.dll"
assembly. From there you'll be able to access certain functions such as
MsgBox...

Microsoft.VisualBasic.Interaction.MsgBox(...);

If you're asking how to call you're own functions that you've authored in
VB.NET, then you'll need to compile them into a class lib project and then
add the resulting assembly as a reference in your C# project.
 
Thank you for your quick reply. I am new to .net developement. I tried it
with the code translator but the Rnd() function is still unknown.

How would you translate this code: MyValue = CInt(Int((6 * Rnd()) + 1))

thank you! juvi

--------------------------------------
 
You can use following csharp code for this:

System.Random rr = new System.Random();
MyValue = rr.Next(1, 6);

Sukhdev
 
Back
Top