August 6, 1997

Using The For-Each Syntax On A Private Collection Object

Creating an object that looks and acts like a collection is a good wayto implement a form of inheritance in VB4, where inheritance is not providedby the language. Creating properties for the Count and Item propertiesof your collection is not difficult. Likewise, creating an Add and Removemethod is fairly easy.

Augmenting Error$

In many places, I include Error$ as picked up in an error trap in a descriptive message. I use a function to expand its meaning. I call the function TSS for Time Stamped String to keep it short. It works something like this: MsgBox TSS(Error$) & ” in Mytest”Public Function

Do You Have Access To A Drive Without Opening A File On That Drive

Assume that you have the full path name of a file, and you need to beable to tell if the drive is writeable (that is, if it is a CD-ROM or anetwork drive to which you have write access). Checking the attributesof the file is not enough, because the file

Manage Focus with MDI Toolbars

While developing MDI applications in VB 4.0, you probably have noticed that the cursor on the MDI child disappears when you click on the toolbar on the MDI parent. You cannot navigate through Tab or any other key. To avoid this problem, put this one line of code in the

Printing Problem with Win95

Microsoft is currently working on a printing problem. Visual Basic 3.0 applications running in Windows 95 cannot print to shared printers with an embedded space. If a shared printer has an embedded space in the computer or printer name, the Visual Basic application will generate an Error 482.To work around

The StartMode Property Of The App Object

The StartMode setting in the Options dialog of the Tools menu in VB4determines only whether an application with no startup form continues torun after Sub Main has completed. This allows testing of OLE Automationservers. But the StartMode property of the App object allows you to determinein code whether an application

Use The Sleep API Function Instead Of DoEvents

When in NT or Windows 95, use the Sleep API function instead of DoEvents.DoEvents does this: while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg);} DoEvents spends part of its time watching for other messages in thesame process. This behavior has no value in a preemptive-multitasking operatingsystem. Sleep yields more

Center Your Forms

Add a method in VB 4.0 to center your forms against the screen or aparent form. Create a new project with two forms. Add this code to Form2: Public Sub ShowCentered(Optional vParent, _ Optional vShowMode)Dim oParent As ObjectDim iMode%, iLeft%, iTop% If IsMissing(vParent) Then ‘default is Screen object Set oParent

Don’t Remove Controls Using Tools-References

Use the Tools-Custom Controls dialog instead of Tools-References toremove controls. The project file will show references to all custom controlsin the project’s toolbox, even if they are not used by any window. Usingthe Custom Controls dialog removes the control from the toolbox, whichremoves the reference.

No more posts to show