You better C sharp or you'll VB flat
July 1, 2009 4:41 AM Subscribe
How do you use a Class Library DLL created with C# from VBA?
posted by jozxyqk to computers & internet (1 answer total)
Here at work, we've got some ancient code that is desperately in need of a rewrite, and I'm a bit of a novice when it comes to all the terminologies and interoperability of bits of Windows code.
What we have now is a DLL written in Visual C++ 5.0.
There is also a VBA piece that runs inside Excel.
The Excel code contains lines that look like this:
Declare Sub subname Lib "dllname" (ByVal Arg1 As String, Arg2 As Long, Arg3 As Long)
I've been tasked with catching up with this century and rewriting the DLL in C#/.NET , with as minimal changes as possible to the other pieces.
I know C# is very Java-like, and I'm just starting to learn it (fairly easy language to pick up).
But is there a way to create a DLL in C# that is accessible using the above "Declare Sub" syntax? If so, what is the syntax? Since C# involves class hierarchies I imagine it's a bit different.
If not, then what is the "proper" way to link to a .NET DLL from VBA? Do I have to "register" the DLL and use COM?