December 4, 1999

Use Objptr function to quickly locate an object in a Collection

One of the simplest and most effective uses of the ObjPtr function is to provide a key for quickly locating an object in a Collection. Let’s suppose you have a collection of objects that don’t have a property that can be used as a key to retrieve them in a

Change the blink rate of the caret

You can retrieve and change the blink rate of the flashing caret inside TextBox controls through a couple of simple API functions: Private Declare Function SetCaretBlinkTime Lib “user32” (ByVal wMSeconds As _ Long) As LongPrivate Declare Function GetCaretBlinkTime Lib “user32” () As Long For example you can double the current

Display the dialog to configure a port

The ConfigurePort API function lets you programmatically bring up the system dialog box for configuring a COM or LPT port. The function returns a non-zero value if successful (that is, the dialog appears). Here is the Declare of this function, and an example of its usage: Private Declare Function ConfigurePort

Friend Procedures are faster than Public ones

It might surprise you to learn that Friend procedures are sensibly faster than Public ones. You can prove this yourself by creating an ActiveX EXE project with one Private class and one Public class (Instancing = MultiUse), and then add the following code in both class modules: Public Sub PublicSub(ByVal

Undocumented trick to speed up functions that return array

VB6 functions can return an array. Unlike regular functions that return scalar values or objects, however, you can’t use the name of the function as a local variable where to store intermediate result, and you are forced to work with a temporary local array, and then assign this array to

Better type checking in Variant properties that can accept objects

As explained in the Mistake Bank you need all three flavors of Property procedures to correctly implement a Variant property that can take either an object or a non-object value. Surprisingly enough, in this case you don’t need that the argument of the Property Set procedure be declared As Variant.

Selecting an entire row in a ListView

The ListView control that comes with VB6 lets you select an entire row by setting its FullRowSelect property to True. If you are working with VB5 or you’re using VB6 with the old version of the Microsoft Windows Controls this capability isn’t avaible, but if you have installed the comctl32.dll

Implement Write-Once Read-Many Properties

Creating a read-only property or a write-only property isn’t difficult, as you probably know: just omit the Property Let (or Set, if dealing with objects) or the Property Get procedure, respectively.There are cases, however, when you want to implement a write-only-read-many property, that is, a property that can be assigned

Check whether a serial or parallel port is available

The Open statement also supports special device names such as COM1 or LPT2. You can build on this feature and use the Open command to test whether a given serial or parallel port is available. Here are two functions that perform this task: ‘ Check whether a given COM serial

No more posts to show