Reputation:
I'm curious of the performance comparisons of the two, if you were to write functionally identical programs. I'm working on a project where I'm beginning to think that an addin may be more appropriate given the volume of compare functions I'm needing to do in VBA.
Upvotes: 3
Views: 2198
Reputation: 71167
Depends what these programs do and how they're doing it.
VSTO /.net is faster than VBA and lets you write code that runs on multiple threads. But Excel is COM and ultimately everything needs to get into a STA (Single-Threaded Apartment) pipeline, and managed (.net) code talks to COM through COM Interop, i.e. it talks to Excel via Primary Interop Assemblies, which are slower than "native" VBA.
In other words:
Best could be a hybrid solution: expose user-defined functions in VBA, and make the VBA code call into a referenced COM-visible .net DLL that does the actual computing without even working with Excel interop assemblies.
Well-written VBA code can outperform equivalent VSTO code, too.
I'm beginning to think that an addin may be more appropriate given the volume of compare functions I'm needing to do in VBA.
You can write an Excel add-in in VBA as well. The fewer technologies involved, the less they need to talk to each other; at the end of the day it's a balance between how much importance you give to a number of things, that may apply differently depending on your requirements, environment and experience:
Upvotes: 14