If the VB code is in a class library, then you can reference and use it like you can a C# class library.
Here is a test to show how this works:
1. Add a C# Console app to a solution
2. Add a VB class library to the solution
3. reference the VB class Library in the C# console app
4. use the following code:
VB Class Library
Public Class Class1
Public Function GetString() As String
Return "Hello from VB!"
End Function
End Class
C# Console app
namespace ConsoleTest
{
class Program
{
static void Main(string[] args)
{
var vbClass = new ClassLibrary1.Class1();
Console.WriteLine(vbClass.GetString());
Console.ReadKey();
}
}
}
5. Now compile and run and it will work. :)
** Property Test update
VB Class Library
Public Class Class1
Public Function GetString() As String
Return "Hello from VB!"
End Function
Private test As String
Public Property TestProperty() As String
Get
Return test
End Get
Set(ByVal value As String)
test = value
End Set
End Property
End Class
C# Console app
using System;
namespace ConsoleTest
{
class Program
{
static void Main(string[] args)
{
var vbClass = new ClassLibrary1.Class1();
Console.WriteLine(vbClass.GetString());
vbClass.TestProperty = "This is a VB property test";
Console.WriteLine(vbClass.TestProperty);
Console.ReadKey();
}
}
}
Output
Hello from VB!
This is a VB property test
** Update 2: Accessing VB Property with paramater
Intellisense had the answer for you. See below:
VB Class Library
Imports System.Runtime.CompilerServices
Public Class Class1
Public Function GetString() As String
Return "Hello from VB!"
End Function
Private test As String
Public Property TestProperty() As String
Get
Return test
End Get
Set(ByVal value As String)
test = value
End Set
End Property
Public Property Message() As String
Get
Return Message(Nothing, Nothing)
End Get
Set(value As String)
Message(Nothing, Nothing) = value
End Set
End Property
Public Property Message(useSQLInfo As Boolean?) As String
Get
Return Message(useSQLInfo, Nothing)
End Get
Set(value As String)
Message(useSQLInfo, Nothing) = value
End Set
End Property
Private flag1 As Boolean?
Private flag2 As Boolean?
Private messageText As String
Public Property Message(useSQLInfo As Boolean?, manageRN As Boolean?) As String
Get
Return messageText
End Get
Set(value As String)
messageText = value
End Set
End Property
End Class
C# Console app
using System;
namespace ConsoleTest
{
class Program
{
static void Main(string[] args)
{
var vbClass = new ClassLibrary1.Class1();
Console.WriteLine(vbClass.GetString());
vbClass.TestProperty = "This is a VB property test";
Console.WriteLine(vbClass.TestProperty);
vbClass.set_Message(true, "test message");
Console.WriteLine(vbClass.get_Message(true));
Console.ReadKey();
}
}
}