July 10, 1999

OverwriteHandler – A class for handling overwrite mode

‘———————————————————‘ OverwriteHandler class” you can associate this class to a form, using the’ Form property, and all the textbox controls in the’ form will support insert/overwrite mode switching” Usage: Dim ov As New OverwriteHandler” Private Sub Form_Load()’ Set ov.Form = Me’ ‘ if you want block-shaped caret in ov mode’

Polymorphic array procedures

You can create “polymorphic” routines that work with any type of array (except arrays of fixed-length strings, or UDTs) by using Variant parameters. Take for example the following code: Function Sum(arr As Variant) As Variant Dim i As Long For i = LBound(arr) To UBound(arr) Sum = Sum + arr(i)

Use function name as a local variable

Many programmers don’t realize that it is perfectly legal to use the name of a function inside the Function itself, as if it were a local variable. This trick often lets you avoid the declaration of a temporary variable, and sometimes can speed up the code. Take for example the

Quickly build a simple About form

If you need a quick-and-dirty About dialog box for your application, that maintains a consistent look with other Windows applications, look no further than the ShellAbout routine in SHELL32.DLL. Using this function you have little control on what the dialog displays, and you can only customize the Product’s name, a

Return a Dos error code on exit

At times you may want to return a Dos ErrorLevel when closing your VB application. This can be necessary, for example, if the EXE is meant to be called from a batch file. Exiting the program with an error code is really simple, and requires only a call to the

Create Timer Threads Using the Swing Timer Class

The Swing package, which is now a standard API package in Java 2, offers a new timer utility. This utility is implicitly threaded and lets you create as many timer threads as required, while taking away the burden of managing these threads. To use a Swing timer, you need an

Count How Many Items Have Been Selected

The SELECT element includes an options array that is accessible from JavaScript. You can use a loop to iterate through this array and count how many choices the user has selected. For each one, the option’s selected property will be true. The countSelect() function in this code does just that