The Latest

DevX - Software Development Resource

Don’t use SetFocus on invisible controls

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

DevX - Software Development Resource

Load a text file in one operation

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 =

DevX - Software Development Resource

Fixed-length strings allocate and deallocate faster

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

DevX - Software Development Resource

Enhanced For-Next loops

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

DevX - Software Development Resource

IsMissing returns False with non-Variant arguments

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

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

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

ComputerName – The name of the local computer

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

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

Create stand-alone type libraries

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

DevX - Software Development Resource

Passing Public class variables by reference

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

DevX - Software Development Resource

Properties of Static Storage

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

DevX - Software Development Resource

Using the Bulk Copy Program Properly

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

DevX - Software Development Resource

Specifying the Locale

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

DevX - Software Development Resource

Line Numbers Missing From Stack Trace

You may have seen “(Compiled Code)” in a stack trace and wondered why a line number was not displayed instead. This occurs because as of release 1.1.5 of the Java

DevX - Software Development Resource

Make the Ants March

To implement a quick and easy version of the old “marching ants” line around a control, place two CommandButtons, a Shape, and a Timer control on a form. Then insert

DevX - Software Development Resource

Using an Associative Array

An associative array (also called map or dictionary) is an array for which the index does not have to be an integer. An associative array stores pairs of values. One

DevX - Software Development Resource

Implement a ListView ItemDoubleClick Event

Double-clicking an icon or file name in Explorer is the standard way of launching an application in Windows. However, if you’re developing an app that uses the ListView control from

DevX - Software Development Resource

Ensure Foolproof Data Entry Times

Asking users to enter time values can often lead to problems formatting what the user enters. I use this piece of code to create a drop-down list of hours, minutes,

DevX - Software Development Resource

Use Custom Form Properties

You can easily find out whether your user clicked on OK or on Cancel on a modal dialog. This example also prevents the user from unloading the form, and thereby

DevX - Software Development Resource

Keep Your Clustered Index’s Weight Down

In SQL Server 7, a significant change was made to the way nonclustered indexes work when a clustered index exists on a table. In version 6.5, the nonclustered index used

DevX - Software Development Resource

Prevent Browsers From Caching ASP Pages

Whenever you are programming in Active Server Pages, make sure that your browser is set to check for a new page every time. Otherwise, you may not see your latest

DevX - Software Development Resource

Stream Unique Identifiers

While attempting to deserialize (or unmarshal) a serialized object instance, you may generate an exception with a message similar to: java.rmi.UnmarshalException: Error unmarshaling return; nested exception is: java.io.InvalidClassException: RMIParm; Local

DevX - Software Development Resource

What’s in Name Mangling?

Name mangling, (the more politically correct term is name-decoration, although it is rarely used) is a method used by a C++ compiler to generate unique names for identifiers in a

DevX - Software Development Resource

Do You Know What Your Identity Is?

Everyone by now is familiar with how to create auto increment keys in SQL Server–just define an integer column with identity (start,increment) and you are set. To create a new

DevX - Software Development Resource

Primary Key Should Not be Clustered

By default, when you define a primary key in the create table statement, it uses a clustered index. However, a clustered key is best used to support queries that return

DevX - Software Development Resource

Debug Problems in Your GridBagLayout Code

The GridBagLayout is a flexible layout manager, but is also notoriously difficult to use. Some of the most common and difficult to debug problems occur when the amount of space