Tip Bank

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

Hidden Variant variables

Variants are the default type of variables that are declared without an As clause, as in: Dim name ‘ this is a variant or are not declared at all (which

DevX - Software Development Resource

Property Procedures in BAS modules

Visual Basic supports Property procedures to implement properties in your own CLS and FRM modules. However, it turns out that you can use Property procedures even within BAS code modules.

DevX - Software Development Resource

Benchmarks with millisecond accuracy

The Timer function returns a value which is only accurate to about 55 milliseconds, therefore it is not very useful for doing accurate benchmarks. If you need a better resolution

DevX - Software Development Resource

Use DataChanged with unbound controls

When you need to learn if a field has been changed by the user, you have at least three options: you can use a global boolean variable and set it