July 30, 1997

More Versatile Array Parameters

You can write a single procedure that accepts any type of array as an argument by using a variantparameter. Within the procedure, address the array using the usual syntax: ‘ return the number of itemsFunction ItemCount(anArray As Variant) _ As LongItemCount = UBound(anArray) – _ LBound(anArray) + 1’ the first

Easy CR/LF Padding

When I write text in message boxes, labels, and so on, and I need to include a carriage return/line feed, I use this function, passing it the number of CR/LFs I need. This saves a lot of typing and looking up of ASCII values: Sub cmdDelete_Click() msg = “Are you

The Address of a Variable

THE ADDRESS OF A VARIABLEVB5 includes a built-in VarPtr function (see tip “Use the Object Browser to Discover UndocumentedFeatures”), but this function isn’t available in VB4. The VB4 runtime library does include this function, butyou must declare it first:#If Win16 ThenDeclare Function VarPtr Lib _ “VB40016.DLL” (variable As Any) _

Cross Midnight Benchmarks

Traditionally, VB programmers benchmark their code using the Timer function. However, if your processmight terminate on the following day, you must take into account that the value returned by that function isreset at midnight. If you’re satisfied with one-second precision, you can simplify your code using the Nowfunction: Dim startTime

App.Path Might Return UNC Path Specifications

Unlike VB4, VB5””””s App.Path property might return a UNC path, such as “\serverprograms…”), undercertain circumstances, depending on how the program started and if it””””s interpreted in the VB IDE orcompiled as a standalone EXE. This change likely affects all applications that use App.Path to set the currentdirectory when the program

Use Object Browser to Discover Undocumented Features

If you right-click on the right-most pane of the Object Browser, you can issue the Show Hidden Members command. From this point on, the Object Browser shows all hidden properties and methods in any library, and you can use it to explore all object libraries in more detail. For instance,

Friendly Enumerated Values

If you build an ActiveX control that exposes an enumerated property, you should define a Public Enumstructure that gathers all the possible values for that property. Doing this helps the developer that uses yourcontrol because the enumerated values will be listed in a combo box in the Property window.However, at

Standalone Type Libraries

If you create out-of-process OLE servers, Visual Basic embeds the companion type library into the EXE fileand generates no TLB file. However, if you own the Enterprise Edition of VB4 or VB5, you can flag theRemote Server File check box to have Visual Basic create a standalone type library. In

Implementation of Public Forms and Class Variables

The implementation of Public variables in forms and classes changed with Visual Basic 5.0. VB4 implementspublic variables in forms and class modules as if they’re regular variables, using pointers to data in memory.In VB5, public variables are more correctly implemented as a pair of hidden Get/Let property procedures.This approach slows

No more posts to show