It is no secret VB is more often than not, a language that produces relatively slow machine code. This is the price we, VB programmers, pay for its extremely ease of use. But there have always been people trying to improve this slowness intrinsic in all VB programs. An example of this is the use of Windows API functions. They provide extremely fast access and processing of data. Of course, once you start using that, you stop getting a few benefits from the Visual Basic libraries, such as automatic reallocation of buffers and such. But hey, I think it is an OK price for what we get. I completely support the use of APIs and tricks in VB. They are good improvements to VB, and they are fun (most of the time).
In this small article, I will be showing how to use the CopyMemory API sub (known as rtlMoveMemory) to keep an array sorted all the time without much hassle, and by hassle I mean a For..Next loop. Such a loop is normally fast, but when you are handling lots of data, and you continously insert and remove items, this loop becomes a bottleneck for the program flow.
Comments