June 5, 1999

Capturing the Output of a MS-DOS Program

Have you ever heard of redirected input or consoleapplications? Have you ever had the need to launch MS-DOS programs, wait for them toterminate, and then dump their output to screen? Let’s see how to accomplish all thisleveraging Win32 and Visual Basic. Outside the exciting and pretty ideal world of the

Static Variables are slower than Dynamic ones

Referencing a static local variable in a procedure is 2-3 times slower than a regular local, dynamic variable; if you want to really speed up your procedures, convert all static variables into module-level variables. The only drawback to this approach is that the procedure become less self-contained and if you

Manufacture a Missing value

Visual Basic doesn’t provide you with a means for creating a Missing value, a feature that in some cases would prove useful in order to simplify the syntax of calls to procedures that expects a variable number of arguments. It isn’t difficult, however, to create such a value programmatically, as

UseMnemonics property for bound Label controls

If your forms contain Label controls used to display data from a database, set their UseMnemonic property to False. In fact, if you leave this property to its default value (True), ampersand “&” characters won’t be showed correctly, and the Label will mistakenly react to hotkeys.

Items of ParamArray can be Missing

When using the ParamArray keyword within a procedure, always remember that when the procedure is invoked from elsewhere in the program one of the argument might be omitted, and you should keep this into account. Here is an example of a routine that uses ParamArray: Function Max(ParamArray args() As Variant)

Correct usage for binary compatibility settings

When working on an updated version of a COM component, you should always enforce Binary Compatibility in the Component tab of the Project Properties dialog box. When enforcing binary compatibility there are a number of common mistakes that you should stay clear of:Always use the last EXE or DLL that

LoadImageList – Reload the images in an ImageList control

Private Declare Function ImageList_ReplaceIcon Lib “COMCTL32” (ByVal hImageList _ As Long, ByVal i As Long, ByVal hIcon As Long) As Long’ Load a set of images from a disk file to a ImageList control’ The file must have been saved using the SaveImageList control, and the’ target ImageList control must

SaveImageList – Save the images in an ImageList control

‘ Save all the images in an ImageList control to a disk file’ Images can be later loaded in the same ImageList control using the’ LoadImageList routine” Note 1: if the file exists, it is overwritten’ Note 2: this routine always save the contents of the ListImages collection’ as it

Counting Bits

It seems that the only way to count the number of 1’s or 0’s in a binary value is creating a loop that iterates on all the 16 or 32 bits of the number. There is, however, a faster algorithm: Function BitCount (ByVal number As Long) As Integer Dim bits

No more posts to show