VB versus VBA
-
Hi, As part of a short-term project to speed up a clients model, I have taken a financal model written in VBA and put it into VB, which I've compiled. However, the compiled VB model runs a little slower than the VBA. I had expected to get some speed gains, but not to have something that runs more slowly! Does anyone have any idea why this might be the case or pointers on how I might identify the problems? Searching on Google and Microsoft haven't thrown up any answers. Thanks, John.
-
Hi, As part of a short-term project to speed up a clients model, I have taken a financal model written in VBA and put it into VB, which I've compiled. However, the compiled VB model runs a little slower than the VBA. I had expected to get some speed gains, but not to have something that runs more slowly! Does anyone have any idea why this might be the case or pointers on how I might identify the problems? Searching on Google and Microsoft haven't thrown up any answers. Thanks, John.
There's no way to tell without knowing anything about your code, what it's doing, where the slowdown is, ... Overall, the compiled VB6 executable should be faster than VBA, but that depends on a lot of things...
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
There's no way to tell without knowing anything about your code, what it's doing, where the slowdown is, ... Overall, the compiled VB6 executable should be faster than VBA, but that depends on a lot of things...
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007Hi Dave, The code is a large financial model. It uses multiple classes and reads/writes to SQL server 2000 DB at the start and end. In short, the vast majority of the code is math operations - mostly fairly simple ones. There are also quite a lot of arrays which are read/written to. Both models use the same range of COM objects for further functionality. Can you outline some of the more common issues resulting in slower compiled VB6 code? Many thanks, John.
Dave Kreskowiak wrote:
There's no way to tell without knowing anything about your code, what it's doing, where the slowdown is, ... Overall, the compiled VB6 executable should be faster than VBA, but that depends on a lot of things...
-
Hi Dave, The code is a large financial model. It uses multiple classes and reads/writes to SQL server 2000 DB at the start and end. In short, the vast majority of the code is math operations - mostly fairly simple ones. There are also quite a lot of arrays which are read/written to. Both models use the same range of COM objects for further functionality. Can you outline some of the more common issues resulting in slower compiled VB6 code? Many thanks, John.
Dave Kreskowiak wrote:
There's no way to tell without knowing anything about your code, what it's doing, where the slowdown is, ... Overall, the compiled VB6 executable should be faster than VBA, but that depends on a lot of things...
jgrogan wrote:
Can you outline some of the more common issues resulting in slower compiled VB6 code?
You mean some of the millions of possibilities?? Seriously, it comes down to the quality of the code and exactly what it's doing. You also might have too much in the way of expectations on how fast the code should run compared to the VBA version. You might get 25% out of the VB6 version, if you're lucky. There are sections that will run faster, but this is limited to stuff that does NOT include database access, math operations, and COM objects, interprocess communication, among others. VBA isn't interpreted as much as you may think. It still gets compiled, but on a method by method basis when it's needed.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007