April 20, 1999

Enum constants that include spaces

If you’re writing an ActiveX control, you can create properties that return an enumerated value, as in: Public Enum SizeConstants SizSmall = 1 SizMedium SizLargeEnd EnumPublic Size As SizeConstants When

Never use the GetLastError API function

If you heavily use API calls and strictly follow the SDK documentation, you might be tempted to use the GetLastError API to retrieve the error returned by your last API

The status of mouse buttons

Visual Basic lets you test the state of mouse buttons only inside a MouseDown, MouseMove, or MouseUp event procedure. To determine the current state of mouse buttons you can use

Interpreted or Compiled?

It is highly unfortunate that Visual Basic doesn’t offer a way to execute a group of statements only when the program is interpreted in the environment or only when it

The number of dimensions of an array

Using “pure” VB, the only way to build a generic routine that returns the number of dimensions of an array passed as an argument is using a loop that repeatedly

Short-circuit evaluation with Select Case

Short-circuit evaluation is an optimization technique automatically adopted by most modern compilers, including all flavors of C++, Borland Delphi and many others. Unfortunately, the Visual Basic compiler is not in

Create a GUID

When you build your ActiveX controls and components, Visual Basic automatically creates all the GUIDs as necessary. The same also happens in other cases, without you even realizing it: for

The status of shift keys

Visual Basic lets you test the state of the Shift, Alt and Ctrl keys only within the KeyUp, KeyDown and all the mouse-related event procedures. If you want to test