August 28, 1998

A Better Way to Swap Two Integer Variables

The algorithm shown in the tip, “Swap Values Using Only Two Variables” [“101 Tech Tips for VB Developers, Supplement to the February 1997 issue of VBPJ, page 25], crashes not only if (a+b) >= 32K, but if (a+b) < -32K also. I usually use this algorithm instead: a = a

Use Arrays, Not Collections

Arrays take less memory and are faster than collections. If you don’t need to use a collection’s keyed lookup, easy extensibility, and other features, use an array instead.

Draw Complex Shapes

You can create complex shapes easily if you have a copy of Microsoft PowerPoint, CorelDraw, or any other graphics editor. Using your graphic editor’s drawing tools, draw the shape you want in the presentation document. PowerPoint features a wide range of drawing tools and autoshapes that let you combine a

Don’t Show me the Hourglass

When creating applications, especially on an enterprise scale, don’t create them so that they run start to finish, tying up the user’s PC needlessly. If all you need is two pieces of information, get it from the user, then use technologies like Microsoft Message Queue (MSMQ) or Microsoft Exchange to