Do you have any examples of using VB6 programming for push-the-envelope?

VB6 had a reputation for forgiving too much (and thereby allowing bad practices) and hiding difficulties that developers might have better than they need to know. But I found that, say, 90% of the applications could be done in VB6.

But I would like to see more examples of push-the-envelope for working with VB6 restrictions. For example, I once found code for using pointers in VB6 by making calls on Windows. As a result, some string manipulations on rather large documents (about 2 MB) were shot down from 30 minutes to a little over 3 seconds. Does anyone have any other examples of passing the limits of VB6?

NB is not VB.Net.

+4
source share
7 answers

Joel said some good things about VB6 back in 2001.

Many VB6 programs are spaghetti, either because they are made so quick and dirty one-time, or because they are written by hacker programmers without training in object-oriented programming or even structured programming.

I wondered what would happen if you take first-class C ++ programmers who sleep in pointers and let them code in VB6. What I discovered at Fog Creek was that they became super efficient coding machines. The code looks pretty good, it is object-oriented and reliable, but you do not waste time using tools that are below the level you need. I wrote code for C ++ / MFC for many years and years of writing code in Visual Basic, and let me tell you, VB6 is much more productive ...

One of the things about Visual Basic 6 is that it does not always give you access to the full Windows repertoire that you need to make a polished application. But what it does, better than almost any other programming environment, allows you to switch to C ++ code (or call the C API) when you are desperate or when you need that extra speed.

It was written in 2001: when creating a new Windows program today IMHO, the obvious choice for better performance is VB.Net or C #. ( JOKE: C # is just Visual Basic with a semicolon .)

Returning to VB6: there are many good examples of how to call the C API to do something special or just run faster. Here are some of my favorite links:

+4
source

One nasty trick was to abuse CallWindowProc to call arbitrary code by passing it a pointer. This technically violates this functional contract, since it should only be used with handles (and not with direct code pointers) received through GetWindowLong ; but in practice, so few people actually know this, that the implementation is forced to allow arbitrary code pointers. This allows you to call any function pointer if it is stdcall , and accepts 4 arguments of the same size as the WndProc arguments.

One even more unpleasant trick, which is a consequence of the above, is that you can dynamically generate code this way - just insert it into the byte array and use CallWindowProc to go to it. This way you can embed your own code without VB6 in a VB6 application without any external DLLs. Of course, at this age, the NX bit is turned on by default, probably this is not such a good idea (if it ever was, that is) ...

+6
source

I'm not sure what he puts in his sandwiches, but almost everything that is in Matthew Curland Advanced Visual Basic 6 is the use of VB6 software. Really wonderful stuff.

+4
source

You cannot miss this unanswered question that mentions Bruce McKinney's Hardcore Visual Basic, which is now (wonderfully) available online:

http://vb.mvps.org/hcvb.asp

This is a great reader who clearly loves the spirit of Basic.

+3
source

Understanding that most of the Gang of Four design patterns rely on an interface implementation rather than inheritance, and therefore it can be easily used in Visual BASIC 6.

Being able to do this greatly improved the design of my CAD / CAM application.

+2
source
+1
source

Paul Caton Subclassing, a continuation of LaVolpe ( http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=68737 ) allows you to do everything you need to connect to Windows events without an IDE Failure. With this, you can implement everything you need on Windows. Samples have crazy things that you might never have thought could be possible.

0
source

All Articles