Since Matt Curland and I published examples of vtable modification using Visual Basic, we have received a number of comments either that this technique was their programming salvation to suggestions that we be incarcerated for this irresponsible hack. Is Not Supported. I disagree with him on vtable mods, on the basis that vtable modification is not a hack, it fills a need that can t be otherwise addressed, and it can be safely encapsulated in a compiled module. That s not to say that you should encourage entry level coders to build quicksort routines with vtable mods, but that there are valid cases for the technique.
Lets revisit exactly what vtable modification is, and take a look at some of the pros and cons.
There are several good reasons you might ever want to modify a class s vtable. The primary one results from the fact that VB s Implements keyword only works with OLE types that are VB-friendly. Since VB automatically manages the IUnknown and IDispatch interfaces for you, you have no control over the actual return value of a function in a class module. The technique isn t complex. The AddressOf operator allows you to get the address of this standard module function.