Tip Bank

DevX - Software Development Resource

IsWindowsNT – Check Windows platform

Private Declare Function GetVersion Lib “kernel32” () As Long’ Returns True is executed under Windows NT,’ False if executed under Windows 95/98Function IsWindowsNT() As Boolean IsWindowsNT = (GetVersion() And &H80000000)

DevX - Software Development Resource

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

DevX - Software Development Resource

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

DevX - Software Development Resource

Change caret size and blink rate

You can alter the size of the caret (this is the name of the cursor within text boxes, not to be confused with the mouse cursor), for instance to ease

DevX - Software Development Resource

WindowsVersion – The version number of the operating system

Private Type OSVERSIONINFO dwOSVersionInfoSize As Long dwMajorVersion As Long dwMinorVersion As Long dwBuildNumber As Long dwPlatformId As Long szCSDVersion As String * 128End TypePrivate Declare Function GetVersionEx Lib “kernel32” Alias

DevX - Software Development Resource

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

DevX - Software Development Resource

Beware of Defxxx directives

Every now and then I see DefInt or DefLng directives spread over Visual Basic code modules, whose intended purpose is to revert the default data type from Variant to Integer

DevX - Software Development Resource

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