Don’t get me wrong. Access VBA can perform very well in most situations. There have been a few times where I’ve needed to improve the speed of some function I was using and Access just took too long.
One of those is hashing values for files. There is a hashing algorithm out there for VBA that will create an MD5 string from the contents of a source string. The shorter the string, the faster it performs. But getting the file contents into a file or system stream object and then processing it using the function takes a long time the more characters that are in the file. And it’s not on the order of milliseconds, but in the order of seconds. This can be ok for a file, but if you’ve got a whole folder of them you are comparing to stored file hashes in your db to see if they’ve changed, that just takes too long when you’ve got 20 files and each one takes 2 seconds.
In this case, I used DevHut’s Daniel Pineault’s VBA PowerShell Function to utilize a PowerShell command to return a string of all the file hashes for files in a folder and just parse that. The function itself takes a couple seconds to run, but it is much faster for getting a folder’s worth of hashes.
Other things that require cryptography tend to be slow if encrypting or decrypting large amounts of data, or trying to do constraint modeling realtime for problems like auto routing and auto populating schedules and conference brackets. Sometimes you just have to use an API to another app or run the calculations separately and store the results for later use. Have you ever run into anything like this?
Hi Jonathan, my go-to solution when I need more speed/performance than VBA can provide (and there is no Windows API function that is specific to the need) is to use ‘COM interop’ … creating my own Type Library using the .NET Framework (and the C# language in my case, though VB.NET and other .NET languages can be used) then VBA can call the public methods of that Type Library.
I created an article on how to do this in my own blog here https://www.thevbahelp.com/post/calling-c-sharp-code-from-vba-com-interop (hope you don’t mind the plug!)
I love Access and VBA, but not only is it SLOW with some things, but it’s actually impossible to do a lot of stuff that you might want to do. I’ve found myself shelling out to batch files, PowerShell scripts, or even Python to do things like FTP files, edit images, post articles to various websites, etc.