Since 1998, DevX has helped people start businesses, build websites, and provide enterprise technology to people globally. Interviewing the likes of Microsoft’s co-founder, Steve Ballmer, the publication brings comprehensive, reliable, and accessible insights to the Internet.








Any action that affects a form’s size or position should be inhibited when the form is minimized or maximized, because this causes a runtime error 384. Always double check your
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
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
By default, textbox controls work in insert mode, where each new character never overwrites existing ones. If you wish to implement overwrite mode you can take advantage of the fact
The single statement that is most useful to avoid bugs is Option Explicit. Always use it in every module of your applications. Even better, let the Visual Basic IDE automatically
Private Declare Sub CopyMemory Lib “kernel32” Alias “RtlMoveMemory” (dest As _ Any, source As Any, ByVal bytes As Long)’ Return the high word of a Long value.Function HiWord(ByVal value As
Private Declare Function GetSystemDirectory Lib “kernel32” Alias _ “GetSystemDirectoryA” (ByVal lpBuffer As String, _ ByVal nSize As Long) As Long ‘ The path of the System directoryFunction SystemDirectory() As String
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
Private Declare Function GetWindowsDirectory Lib “kernel32” Alias _ “GetWindowsDirectoryA” (ByVal lpBuffer As String, _ ByVal nSize As Long) As Long’ Return the path of the Windows directoryFunction WindowsDirectory() As String
Private Declare Function GetUserName Lib “advapi32.dll” Alias “GetUserNameA” _ (ByVal lpBuffer As String, nSize As Long) As Long’ The name of the interactive userFunction UserName() As String Dim buffer As
‘ Return True is a string is made only of spaces, tabs, and Null characters.’ This function is especially useful to test whether fixed-length strings ‘ are initialized.Function IsNullString(Text As
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.
The Tag property exposed by many Windows Common Controls (including TreeView’s Node objects and ListView’s ListItem objects) is more versatile than the ListBox and ComboBox controls’ ItemData property, because it
Visual Basic’s documentation does not explain how to specify more than just one conditional compilation constant in the Advanced tab of the Options dialog. The correct way is using a
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
In the Show event of a form you might be tempted to use SetFocus to select which field the end user should begin working with. However, this method raises an
The fastest way to read a text file is using the Input$ function, as shown in this reusable procedure: Function FileText (filename$) As String Dim handle As Integer handle =
Fixed-length strings are generally slower than conventional strings, because all VB string functions and operators only recognize conventional strings, thus all fixed-length strings must be transparently converted to and from
At times you may need to execute the same block of statements for different values of a variable, but you can’t use a straight For Next loop because the sequence
Every now and then I forget that the IsMissing function always returns False when the argument is not a Variant value. This happens because IsMissing does nothing more than converting
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
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)
Private Declare Function GetComputerName Lib “kernel32” Alias _ “GetComputerNameA” (ByVal lpBuffer As String, nSize As Long) As Long’ Returns the name of the computer.Function ComputerName() As String Dim buffer As
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
Many VB programmers assume that Visual Basic 5.0 is not capable of creating stand-alone Type Libraries, because the documentation states that when an ActiveX component or control is created, the
Under VB4 Public variables in form and class modules were implemented in the same manner as variables in BAS modules, that is, as direct references to memory locations. This allowed
Global objects, static data members of a class, namespace variables, and static variables in functions reside in static memory. Static objects are allocated by the linker and their address remains
A common technique in Active Server Pages (ASP) is to use server-side code to check that the user has filled in a form. In effect, you submit the ASP page
The Bulk Copy Program is still a handy utility for transferring data in and out of tables in SQL. However, using it properly requires that you learn the various command
Closely related to the issue of internationalization is the java.util.Locale class. An instance of Locale represents a geographic, political, or cultural region, and may or may not correspond to a





