Code Samples, Tips, Tricks and
other Neat Stuff for the VB developer

All Content Copyright 2000
New Vision Software
All rights reserved

VB Petition

Many of you may not be aware that Microsoft's mainstream support for VB6 officially ended on March 31st, 2005.  Now that this has occurred, it becomes increasingly more likely that future updates to Windows may break existing VB code.  If you are concerned about this and/or are concerned about migration issues associated with bringing existing VB code to the .NET platform, please take a moment to read and sign the petition asking Microsoft to extend there COM based VB product line.  The impetus behind the petition is the desire to give companies and individuals with substantial investments in existing VB code a path forward to the latest development platform without the current requirement for wholesale rewrites of existing code.  Thanks for your support!




All Sample Projects

Grouped Samples

Common Dialogs

Control Stuff

Date & Timezone




File Routines

Form Modifications

Icon Routines

Listbox & ComboBox




Text Parsing Routines

UserControl Demos

Specific Samples

Activate Previous


API & OLE DragDrop

Environment Variables



Message Box



File Split Utility

Save Clipboard Utility

Visual Basic Tips!


 Care And Feeding Instructions

For The DbgWProc Debug DLL

The DbgWProc dll is the best thing since sliced bread when it comes to subclassing.  When used, it allows breaking in debug mode in the VB IDE without the crashes that are normally associated with break mode and subclassed code.  The following is a description of the proper installation and use of this tool.

You can install the DbgWProc dll anywhere on your system.  Because the dll is a COM library, it must be registered before it can be used.  To register the lib, you must use regsvr32.exe.  The most straightforward way to accomplish this registration is to place the DbgWProc lib in the System or System32 folder (depending on your OS) and then, in Windows Explorer, drag the DbgWProc.dll file and drop it on the regsvr32.exe file.  Regsvr32.exe will handle the rest.

Once the library is registered, you will be able to set a reference to it in the references dialog in the VB IDE.  The entry in the Available References list is: "Debug Object for AddressOf Subclassing"  After the reference is set, you should be able to declare a variable of type WindowProcHook.  For further details on how to setup a subclass, see Subclass Demo (Advanced).

Now that you have implemented the subclassing code, there are a couple of points to remember when running subclassed code in the VB IDE. 

  • First and foremost, NEVER use the Stop button.  Using the Stop button does not allow the un-subclassing code to execute which leads to a certain crash of the IDE.  You should also remove any End statements from your code since End has the same effect as using the Stop button.

  • If you have more than one subclass for a given object, make sure you unsubclass each subclass in the reverse order in which you subclassed the object.  This is to avoid orphaning the original window proc for the object, which would cause a crash.

  • When you compile your application, don't forget to set the conditional compilation variable in the Make tab of the Project Properties dialog to '0' (zero) (see Subclass Demo (Advanced)).  If you don't, a message will be displayed stating the DbgWProc lib is not needed for running compiled code when your subclass code is accessed in the compiled app.

With proper use of the DbgWProc lib, subclassing in VB becomes a very stable and useful operation.  Happy Subclassing!